Tune a bit the Idea configuration for the project.
[Persons_Comparator.git] / src / Size.java
index dfea96cdd8226c8dba12b50fa86423ceb2635658..c2392073b34662affdc474f619a1ab27519e2a98 100644 (file)
@@ -1,5 +1,4 @@
-
-public class Size {
+public class Size implements Comparable<Size> {
     private int max = 240;
     private int min = 20;
     private int size;
@@ -23,4 +22,14 @@ public class Size {
     private boolean validateSize(int size) {
         return (size > max || size < min);
     }
+
+    @Override
+    public int compareTo(Size size) {
+        int distance = size.size - this.getSize();
+        if (distance >= 0)
+            return distance;
+        else
+            return -distance;
+
+    }
 }