Implement the person comparator :
[Persons_Comparator.git] / src / Size.java
index a61f24cb79769b34c3a8e8b502542621232a81ed..eb8003f542104a9249658a2b118a8f758c0f8814 100644 (file)
@@ -1,6 +1,7 @@
-public class Size implements Comparable<Size> {
+public class Size {
     private int max = 240;
     private int min = 40;
+    private int defaultSize = 160;
     private int size;
 
     Size() {
@@ -18,6 +19,10 @@ public class Size implements Comparable<Size> {
         return max;
     }
 
+    public int getDefaultSize() {
+        return defaultSize;
+    }
+
     public int getSize() {
         return size;
     }
@@ -34,13 +39,8 @@ public class Size implements Comparable<Size> {
         return (size >= getMin() && size <= getMax());
     }
 
-    @Override
-    public int compareTo(Size size) {
+    public int distanceTo(Size size) {
         int distance = size.getSize() - this.getSize();
-        if (distance >= 0)
-            return distance;
-        else
-            return -distance;
-
+        return Math.abs(distance);
     }
 }