From 1c1189337121a1baa74961813e619c99b398a333 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Tue, 8 Jan 2019 15:14:55 +0100 Subject: [PATCH] Make Person class and attributes implements Comparable. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/Eye.java | 15 +++++++++++---- src/Firstname.java | 7 ++++++- src/Origin.java | 7 ++++++- src/Person.java | 7 ++++++- src/Size.java | 8 +++++++- src/Weight.java | 7 ++++++- 6 files changed, 42 insertions(+), 9 deletions(-) diff --git a/src/Eye.java b/src/Eye.java index b02dbfc..abbbfb7 100644 --- a/src/Eye.java +++ b/src/Eye.java @@ -1,9 +1,11 @@ import java.awt.Color; +import java.util.List; -public class Eye { +public class Eye implements Comparable { private Color color; + private List colorList; - Eye(Color color) { + Eye(String color) { setColor(color); } @@ -11,7 +13,12 @@ public class Eye { return color; } - public void setColor(Color color) { - this.color = color; + public void setColor(String color) { + this.color = Color.getColor(color); + } + + @Override + public int compareTo(Eye eye) { + return 0; } } diff --git a/src/Firstname.java b/src/Firstname.java index 2535c0e..91e8d75 100644 --- a/src/Firstname.java +++ b/src/Firstname.java @@ -1,4 +1,4 @@ -public class Firstname { +public class Firstname implements Comparable { private String firstname; public String getFirstname() { @@ -8,4 +8,9 @@ public class Firstname { public void setFirstname(String firstname) { this.firstname = firstname; } + + @Override + public int compareTo(Firstname firstname) { + return 0; + } } diff --git a/src/Origin.java b/src/Origin.java index 72ecd83..60e7fc9 100644 --- a/src/Origin.java +++ b/src/Origin.java @@ -1,4 +1,4 @@ -public class Origin { +public class Origin implements Comparable { private String country; Origin(String country) { @@ -12,4 +12,9 @@ public class Origin { public void setCountry(String country) { this.country = country; } + + @Override + public int compareTo(Origin origin) { + return 0; + } } diff --git a/src/Person.java b/src/Person.java index 56a02a8..387e921 100644 --- a/src/Person.java +++ b/src/Person.java @@ -1,6 +1,6 @@ import javax.swing.*; -public class Person extends JPanel { +public class Person extends JPanel implements Comparable { private Firstname firstname; private Origin origin; private Size size; @@ -50,4 +50,9 @@ public class Person extends JPanel { public Eye getEye() { return eye; } + + @Override + public int compareTo(Person person) { + return 0; + } } diff --git a/src/Size.java b/src/Size.java index dfea96c..a526fab 100644 --- a/src/Size.java +++ b/src/Size.java @@ -1,5 +1,6 @@ +import java.util.Comparator; -public class Size { +public class Size implements Comparable { private int max = 240; private int min = 20; private int size; @@ -23,4 +24,9 @@ public class Size { private boolean validateSize(int size) { return (size > max || size < min); } + + @Override + public int compareTo(Size size) { + return 0; + } } diff --git a/src/Weight.java b/src/Weight.java index 2a8c812..b0264fa 100644 --- a/src/Weight.java +++ b/src/Weight.java @@ -1,4 +1,4 @@ -public class Weight { +public class Weight implements Comparable { private int weight; Weight(int weight) { @@ -20,4 +20,9 @@ public class Weight { private boolean validateWeight(int weight) { return (weight > 0); } + + @Override + public int compareTo(Weight weight) { + return 0; + } } -- 2.34.1