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. * To show a bit example of java basics.
*/ */
public class Main { public class Main {
// Constants // 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 FIRST_NAME = "Jérémi"; // jeremi firstname as a constant (can't be edited during run)
private static final String LAST_NAME = "Nihart"; private static final String LAST_NAME = "Nihart";
// Main function // Main function
public static void main(String[] args) { public static void main(String[] args) {
Person jeremi = new Person(FIRST_NAME, LAST_NAME); // create a jeremi person with main constructor 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 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.print("We use the toString() function on jeremi :\n==> ");
System.out.println(jeremi.toString()); // debugging jeremi person with the overrided toString() function 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.print("\nWe use the toString() function on unknown :\n==> ");
System.out.println(unknown.toString()); // debugging unknown person with the overrided toString() function 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==> "); System.out.print("\nNow we will edit the firstName of the unknown person :\n==> ");
unknown.setFirstName("Mon nouveau nom :-)"); // updating unknown person firstname unknown.setFirstName("Mon nouveau nom :-)"); // updating unknown person firstname
System.out.println(unknown.toString()); // debugging unknown person with the overrided toString() function 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.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.println(getHi(jeremi.getFullName())); // call getfullname() into gethi() and display
} }
// Hi function // Hi function
private static String getHi(String name) { 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 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 * A class representing a person/human
*/ */
public class Person { public class Person {
// Variables // Variables
private String firstName; // model object local, private variables private String firstName; // model object local, private variables
private String lastName; private String lastName;
// Constructor // Constructor
public Person(String firstName, String lastName) { // complet public Person(String firstName, String lastName) { // complet
this.firstName = firstName; this.firstName = firstName;
this.lastName = lastName; this.lastName = lastName;
} }
public Person() { // surcharge public Person() { // surcharge
this("No first name", "No last name"); this("No first name", "No last name");
} }
// Getter // Getter
public String getFirstName() { // firstname public String getFirstName() { // firstname
return this.firstName; return this.firstName;
} }
public String getLastName() { // lastname public String getLastName() { // lastname
return this.lastName; return this.lastName;
} }
public String getFullName() { // LASTNAME Firstname(first letter) public String getFullName() { // LASTNAME Firstname(first letter)
return String.format("%s %s.", this.lastName.toUpperCase(), Character.toUpperCase(this.firstName.charAt(0))); return String.format("%s %s.", this.lastName.toUpperCase(), Character.toUpperCase(this.firstName.charAt(0)));
} }
// Setter // Setter
public void setFirstName(String newFirstName) { // firstname public void setFirstName(String newFirstName) { // firstname
this.firstName = newFirstName; this.firstName = newFirstName;
} }
public void setLastName(String newLastName) { // lastname public void setLastName(String newLastName) { // lastname
this.lastName = newLastName; this.lastName = newLastName;
} }
@Override @Override
public String toString() { // tostring overrided for debugging public String toString() { // tostring overrided for debugging
return String.format("Person(firstName=\"%s\", lastName=\"%s\")", this.firstName, this.lastName); return String.format("Person(firstName=\"%s\", lastName=\"%s\")", this.firstName, this.lastName);
} }
} }