X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FEye.java;h=822e6f83dd3fc7aabc5bcf5d864671c828c6f999;hb=5687dc10a68b52d28b63151d8c16a45775ef2e77;hp=59612440812c342dd6dd929b91936de79363d337;hpb=480ff9f544cf66c5ee99268f4677a0b389815538;p=Persons_Comparator.git diff --git a/src/Eye.java b/src/Eye.java index 5961244..822e6f8 100644 --- a/src/Eye.java +++ b/src/Eye.java @@ -1,7 +1,7 @@ import java.awt.Color; import java.util.Arrays; -public class Eye implements Comparable { +public class Eye { private String strColor; private Color color; private String[] colorsList = {"black", "blue", "brown", "green"}; @@ -47,10 +47,14 @@ public class Eye implements Comparable { */ public void setColor(String color) { if (validateColor(color)) { - if (color.equals("brown")) + if (color.equals("black")) + this.color = Color.black; + else if (color.equals("blue")) + this.color = Color.blue; + else if (color.equals("brown")) this.color = new Color(88, 41, 0); - else - this.color = Color.getColor(color); + else if (color.equals("green")) + this.color = Color.green; } else { throw new IllegalArgumentException("Color must be" + this.colorListToString()); } @@ -77,8 +81,7 @@ public class Eye implements Comparable { * @param eye * @return */ - @Override - public int compareTo(Eye eye) { + public int distanceTo(Eye 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();