A lib directory to the project with gson library.
[Persons_Comparator.git] / src / Person.java
CommitLineData
f1e9d6d2 1import java.util.ArrayList;
6977e614 2import java.util.Comparator;
97491195 3
6977e614 4public class Person implements Comparable<Person>, Comparator<Person> {
97491195
JB
5 private Firstname firstname;
6 private Origin origin;
7 private Size size;
8 private Weight weight;
9 private Eye eye;
f1e9d6d2
JB
10 //List of persons in the database to compare to.
11 private ArrayList<Person> personArrayList;
97491195 12
6977e614 13 Person(Firstname firstname, Origin origin, Size size, Weight weight, Eye eye) {
97491195 14 setFirstname(firstname);
6977e614
JB
15 setOrigin(origin);
16 setPersonSize(size);
17 setWeight(weight);
18 setEye(eye);
97491195
JB
19 }
20
21 public void setFirstname(Firstname firstname) {
22 this.firstname = firstname;
23 }
24
25 public Firstname getFirstname() {
26 return firstname;
27 }
28
29 public void setOrigin(Origin origin) {
30 this.origin = origin;
31 }
32
33 public Origin getOrigin() {
34 return origin;
35 }
36
37 public void setPersonSize(Size size) {
38 this.size = size;
39 }
40
41 public Size getPersonSize() {
42 return size;
43 }
44
45 public void setWeight(Weight weight) {
46 this.weight = weight;
47 }
48
49 public Weight getWeight() {
50 return weight;
51 }
52
53 public void setEye(Eye eye) {
54 this.eye = eye;
55 }
56
57 public Eye getEye() {
58 return eye;
59 }
1c118933 60
f1e9d6d2
JB
61 public void setPersonArrayList(ArrayList<Person> personArrayList) {
62 this.personArrayList = personArrayList;
63 }
64
65 public ArrayList<Person> getPersonArrayList() {
66 return personArrayList;
67 }
68
1c118933
JB
69 @Override
70 public int compareTo(Person person) {
613054ac
JB
71 return this.firstname.compareTo(person.getFirstname()) + this.origin.compareTo(person.getOrigin())
72 + this.size.compareTo(person.getPersonSize()) + this.weight.compareTo(person.getWeight())
73 + this.eye.compareTo(person.getEye());
1c118933 74 }
6977e614
JB
75
76 @Override
ac6c3ea2
JB
77 public int compare(Person p1, Person p2) {
78 return p1.compareTo(p2);
6977e614 79 }
97491195 80}