A lib directory to the project with gson library.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 10 Jan 2019 10:47:16 +0000 (11:47 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Thu, 10 Jan 2019 10:47:16 +0000 (11:47 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
Persons_Comparator.iml
lib/gson-2.8.5.jar [new file with mode: 0644]
src/Eye.java
src/EyeView.java
src/Main.java
src/MainWindowsView.java
src/Person.java

index 9e63df535372836ff11d9e232cc5572e58fdefee..fb8e8667171815867fbacb554654715987d224b0 100644 (file)
@@ -7,5 +7,6 @@
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" name="lib" level="project" />
   </component>
-</module>
+</module>
\ No newline at end of file
diff --git a/lib/gson-2.8.5.jar b/lib/gson-2.8.5.jar
new file mode 100644 (file)
index 0000000..0d5baf3
Binary files /dev/null and b/lib/gson-2.8.5.jar differ
index a165830f8a1f3cb67354d4c3a97fe48951798c90..ed2231b7aaa81da839726fea50b760f917f178f3 100644 (file)
@@ -62,7 +62,7 @@ public class Eye implements Comparable<Eye> {
         double r_diff = this.getColor().getRed() - eye.getColor().getRed();
         double g_diff = this.getColor().getGreen() - eye.getColor().getGreen();
         double b_diff = this.getColor().getBlue() - eye.getColor().getBlue();
-        // See https://en.wikipedia.org/wiki/Color_difference
+        //See https://en.wikipedia.org/wiki/Color_difference
         Double distance = Math.sqrt(2 * Math.pow(r_diff, 2) + 4 * Math.pow(g_diff, 2) + 3 * Math.pow(b_diff, 2));
         return distance.intValue();
     }
index f88e52eaab8428cf6f785fe8a00c2edd26d1701d..aa54c8b8d76bdf0109e9fc294d8a21d63feacf63 100644 (file)
@@ -11,6 +11,7 @@ public class EyeView extends JComponent {
         this.label.setText("Eyes color");
         this.colorsList = new JList(getEyeObj().getColorsList());
         this.colorsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
+        this.colorsList.setLayoutOrientation(JList.VERTICAL);
         add(label);
         add(colorsList);
     }
index 6937e91dd1a36423a2ff453374736bc0c5e33605..77979dae22387c4523a9cb43dc9b50e57dfc7744 100644 (file)
@@ -5,6 +5,12 @@ public class Main {
         //creating and showing this application's GUI.
         String programName = "Person Comparator";
 
+        Eye blackEye = new Eye("black");
+        Eye greenEye = new Eye("green");
+        Eye blueEye = new Eye("blue");
+        Eye brownEye = new Eye("brown");
+
+        //Person person = new Person();
 
         javax.swing.SwingUtilities.invokeLater(new Runnable() {
             public void run() {
index bc7951152f608bfdd4f8633efc2a9b99120cc8f1..729a9ad20382654cc21213f283a6f455e7d9f0c8 100644 (file)
@@ -5,6 +5,7 @@ import java.awt.event.ActionListener;
 import java.util.ArrayList;
 
 public class MainWindowsView extends JFrame {
+
     MainWindowsView(String title) {
         //Create and set up the window.
         setTitle(title);
@@ -56,5 +57,4 @@ public class MainWindowsView extends JFrame {
         //this.pack();
         this.setVisible(true);
     }
-
 }
\ No newline at end of file
index d1ceb350724cbae919c3642f77b51fa8548278f2..3e6788ffac59805d10321c8671f96d2e8c6bf6cb 100644 (file)
@@ -1,3 +1,4 @@
+import java.util.ArrayList;
 import java.util.Comparator;
 
 public class Person implements Comparable<Person>, Comparator<Person> {
@@ -6,6 +7,8 @@ public class Person implements Comparable<Person>, Comparator<Person> {
     private Size size;
     private Weight weight;
     private Eye eye;
+    //List of persons in the database to compare to.
+    private ArrayList<Person> personArrayList;
 
     Person(Firstname firstname, Origin origin, Size size, Weight weight, Eye eye) {
         setFirstname(firstname);
@@ -55,6 +58,14 @@ public class Person implements Comparable<Person>, Comparator<Person> {
         return eye;
     }
 
+    public void setPersonArrayList(ArrayList<Person> personArrayList) {
+        this.personArrayList = personArrayList;
+    }
+
+    public ArrayList<Person> getPersonArrayList() {
+        return personArrayList;
+    }
+
     @Override
     public int compareTo(Person person) {
         return this.firstname.compareTo(person.getFirstname()) + this.origin.compareTo(person.getOrigin())