Creation of the class Personne
This commit is contained in:
parent
3876e8f71e
commit
f5fc52c00a
1 changed files with 66 additions and 0 deletions
66
src/input/Person.java
Normal file
66
src/input/Person.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package input;
|
||||
|
||||
public class Person implements Input{
|
||||
public String lastName;
|
||||
public String firstName[];
|
||||
public Gender gender;
|
||||
public Person spouse;
|
||||
//public Society society;
|
||||
public String function;
|
||||
|
||||
public Person(String lastName, String[] firstName, Gender gender, Person spouse, String function) {
|
||||
this.lastName = lastName;
|
||||
this.firstName = firstName;
|
||||
this.gender = gender;
|
||||
this.spouse = spouse;
|
||||
//this.society = society
|
||||
this.function = function;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Presentation presentation, Order order) {
|
||||
String out = "";
|
||||
String firstNames = "";
|
||||
switch (presentation) {
|
||||
case SHORT:
|
||||
for (String i: firstName)
|
||||
firstNames += i.charAt(0) + ". ";
|
||||
if (order == Order.FIRST_LAST)
|
||||
out = firstNames + lastName;
|
||||
else
|
||||
out = lastName + " " + firstNames;
|
||||
break;
|
||||
case SIMPLE:
|
||||
out = gender == Gender.MEN ? "Mr. " : "Ms. " ;
|
||||
for (int i = 0; i < firstName.length-1; i++)
|
||||
firstNames += firstName[i].charAt(0) + ". ";
|
||||
firstNames += firstName[firstName.length-1];
|
||||
if (order == Order.FIRST_LAST)
|
||||
out += firstNames + " " + lastName;
|
||||
else
|
||||
out += lastName + " " + firstNames;
|
||||
/*if (society != null)
|
||||
out += " (" + society.socialReason + ")";*/
|
||||
break;
|
||||
case COMPLETE:
|
||||
out = gender == Gender.MEN ? "Mr. " : "Ms. " ;
|
||||
for (String i: firstName)
|
||||
firstNames += i + " ";
|
||||
if (order == Order.FIRST_LAST)
|
||||
out = firstNames + " " + lastName + "\n";
|
||||
else
|
||||
out = lastName + " " + firstNames + "\n";
|
||||
/*if (society != null)
|
||||
out += "\t- Society: " + society.socialReason + "\n";*/
|
||||
if (!function.equals(""))
|
||||
out += "\t- Function: " + function;
|
||||
break;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean research(String search) {
|
||||
return false;
|
||||
}
|
||||
}
|
Reference in a new issue