Add an ArrayList of persons to the Person class.
[Persons_Comparator.git] / src / Eye.java
index ed2231b7aaa81da839726fea50b760f917f178f3..bf83b8a0410ac43b17604fdae45f82f8935aa655 100644 (file)
@@ -36,7 +36,7 @@ public class Eye implements Comparable<Eye> {
                 this.color = Color.getColor(color);
 
         } else {
-            throw new IllegalArgumentException("Color must be " + colorsList);
+            throw new IllegalArgumentException("Color must be" + new Eye().toString());
         }
     }
 
@@ -66,4 +66,14 @@ public class Eye implements Comparable<Eye> {
         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();
     }
+
+    @Override
+    public String toString() {
+        StringBuilder stringBuilder = new StringBuilder();
+        for (String c : colorsList) {
+            stringBuilder.append(" ");
+            stringBuilder.append(c);
+        }
+        return stringBuilder.toString();
+    }
 }