convert indent to space

This commit is contained in:
Jérémi N ‘EndMove’ 2022-08-09 19:08:43 +02:00
parent 8796237412
commit 9e09e3a23b
Signed by: EndMove
GPG Key ID: 65C4A02E1F5371A4
3 changed files with 53 additions and 53 deletions

Binary file not shown.

View File

@ -8,31 +8,31 @@ import eu.endmove.hi.model.Person; // importing Person model
* To show a bit example of java basics.
*/
public class Main {
// Constants
private static final String FIRST_NAME = "Jérémi"; // jeremi firstname as a constant (can't be edited during run)
private static final String LAST_NAME = "Nihart";
// Constants
private static final String FIRST_NAME = "Jérémi"; // jeremi firstname as a constant (can't be edited during run)
private static final String LAST_NAME = "Nihart";
// Main function
public static void main(String[] args) {
Person jeremi = new Person(FIRST_NAME, LAST_NAME); // create a jeremi person with main constructor
Person unknown = new Person(); // create a unknown person with the constructor surcharge
// Main function
public static void main(String[] args) {
Person jeremi = new Person(FIRST_NAME, LAST_NAME); // create a jeremi person with main constructor
Person unknown = new Person(); // create a unknown person with the constructor surcharge
System.out.print("We use the toString() function on jeremi :\n==> ");
System.out.println(jeremi.toString()); // debugging jeremi person with the overrided toString() function
System.out.print("We use the toString() function on jeremi :\n==> ");
System.out.println(jeremi.toString()); // debugging jeremi person with the overrided toString() function
System.out.print("\nWe use the toString() function on unknown :\n==> ");
System.out.println(unknown.toString()); // debugging unknown person with the overrided toString() function
System.out.print("\nWe use the toString() function on unknown :\n==> ");
System.out.println(unknown.toString()); // debugging unknown person with the overrided toString() function
System.out.print("\nNow we will edit the firstName of the unknown person :\n==> ");
unknown.setFirstName("Mon nouveau nom :-)"); // updating unknown person firstname
System.out.println(unknown.toString()); // debugging unknown person with the overrided toString() function
System.out.print("\nNow we will edit the firstName of the unknown person :\n==> ");
unknown.setFirstName("Mon nouveau nom :-)"); // updating unknown person firstname
System.out.println(unknown.toString()); // debugging unknown person with the overrided toString() function
System.out.print("\nAnd now use the getHi() function with the jeremi full name :\n==> ");
System.out.println(getHi(jeremi.getFullName())); // call getfullname() into gethi() and display
}
System.out.print("\nAnd now use the getHi() function with the jeremi full name :\n==> ");
System.out.println(getHi(jeremi.getFullName())); // call getfullname() into gethi() and display
}
// Hi function
private static String getHi(String name) {
return String.format("Hi %s ! How are you today ?", name); // use a static string formatting util function available in String class
}
// Hi function
private static String getHi(String name) {
return String.format("Hi %s ! How are you today ?", name); // use a static string formatting util function available in String class
}
}

View File

@ -4,44 +4,44 @@ package eu.endmove.hi.model;
* A class representing a person/human
*/
public class Person {
// Variables
private String firstName; // model object local, private variables
private String lastName;
// Variables
private String firstName; // model object local, private variables
private String lastName;
// Constructor
public Person(String firstName, String lastName) { // complet
this.firstName = firstName;
this.lastName = lastName;
}
// Constructor
public Person(String firstName, String lastName) { // complet
this.firstName = firstName;
this.lastName = lastName;
}
public Person() { // surcharge
this("No first name", "No last name");
}
public Person() { // surcharge
this("No first name", "No last name");
}
// Getter
public String getFirstName() { // firstname
return this.firstName;
}
// Getter
public String getFirstName() { // firstname
return this.firstName;
}
public String getLastName() { // lastname
return this.lastName;
}
public String getLastName() { // lastname
return this.lastName;
}
public String getFullName() { // LASTNAME Firstname(first letter)
return String.format("%s %s.", this.lastName.toUpperCase(), Character.toUpperCase(this.firstName.charAt(0)));
}
public String getFullName() { // LASTNAME Firstname(first letter)
return String.format("%s %s.", this.lastName.toUpperCase(), Character.toUpperCase(this.firstName.charAt(0)));
}
// Setter
public void setFirstName(String newFirstName) { // firstname
this.firstName = newFirstName;
}
// Setter
public void setFirstName(String newFirstName) { // firstname
this.firstName = newFirstName;
}
public void setLastName(String newLastName) { // lastname
this.lastName = newLastName;
}
public void setLastName(String newLastName) { // lastname
this.lastName = newLastName;
}
@Override
public String toString() { // tostring overrided for debugging
return String.format("Person(firstName=\"%s\", lastName=\"%s\")", this.firstName, this.lastName);
}
@Override
public String toString() { // tostring overrided for debugging
return String.format("Person(firstName=\"%s\", lastName=\"%s\")", this.firstName, this.lastName);
}
}