Structure the code to respect MVC design pattern.
[Persons_Comparator.git] / src / Person.java
index 387e921dc72689881b21f329e828b242e17ed306..9c30e56c9e4e5d3055f7e1bea97466520a86597a 100644 (file)
@@ -1,14 +1,18 @@
-import javax.swing.*;
+import java.util.Comparator;
 
-public class Person extends JPanel implements Comparable<Person> {
+public class Person implements Comparable<Person>, Comparator<Person> {
     private Firstname firstname;
     private Origin origin;
     private Size size;
     private Weight weight;
     private Eye eye;
 
-    Person(Firstname firstname) {
+    Person(Firstname firstname, Origin origin, Size size, Weight weight, Eye eye) {
         setFirstname(firstname);
+        setOrigin(origin);
+        setPersonSize(size);
+        setWeight(weight);
+        setEye(eye);
     }
 
     public void setFirstname(Firstname firstname) {
@@ -53,6 +57,13 @@ public class Person extends JPanel implements Comparable<Person> {
 
     @Override
     public int compareTo(Person person) {
+        return this.firstname.compareTo(person.getFirstname()) + this.origin.compareTo(person.getOrigin())
+                + this.size.compareTo(person.getPersonSize()) + this.weight.compareTo(person.getWeight())
+                + this.eye.compareTo(person.getEye());
+    }
+
+    @Override
+    public int compare(Person person, Person t1) {
         return 0;
     }
 }