From f5fc52c00a779b5d3f78f3c87a4daa955e4d1863 Mon Sep 17 00:00:00 2001 From: CHARLAIX FLORIAN p1905458 Date: Wed, 1 Apr 2020 16:48:56 +0200 Subject: [PATCH] Creation of the class Personne --- src/input/Person.java | 66 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/input/Person.java diff --git a/src/input/Person.java b/src/input/Person.java new file mode 100644 index 0000000..fe97153 --- /dev/null +++ b/src/input/Person.java @@ -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; + } +}