Make Person class and attributes implements Comparable.
[Persons_Comparator.git] / src / Weight.java
index 3f2a829163130f8bba5c5ed1e22e5fdd0fa916c3..b0264faa591187841e4345f0a94b00e0d9347f63 100644 (file)
@@ -1,4 +1,4 @@
-public class Weight {
+public class Weight implements Comparable<Weight> {
     private int weight;
 
     Weight(int weight) {
@@ -12,10 +12,17 @@ public class Weight {
     public void setWeight(int weight) {
         if (validateWeight(weight)) {
             this.weight = weight;
-        } /* FIXME: raise an error */
+        } else {
+            throw new IllegalArgumentException("Weight cannot be negative or zero");
+        }
     }
 
     private boolean validateWeight(int weight) {
         return (weight > 0);
     }
+
+    @Override
+    public int compareTo(Weight weight) {
+        return 0;
+    }
 }