Finish the WeightView by using a JComboBox.
[Persons_Comparator.git] / src / Weight.java
index 5e33327fac7ec77eac23a14ec0aa46a6b4e65342..4b67611af0eef2f07bfa7437e498d9418298af7c 100644 (file)
@@ -1,4 +1,7 @@
 public class Weight implements Comparable<Weight> {
+    private int min = 2;
+    private int max = 600;
+    private int defaultWeight = 72;
     private int weight;
 
     Weight() {
@@ -8,6 +11,18 @@ public class Weight implements Comparable<Weight> {
         setWeight(weight);
     }
 
+    public int getMin() {
+        return min;
+    }
+
+    public int getMax() {
+        return max;
+    }
+
+    public int getDefaultWeight() {
+        return defaultWeight;
+    }
+
     public int getWeight() {
         return weight;
     }
@@ -16,12 +31,21 @@ public class Weight implements Comparable<Weight> {
         if (validateWeight(weight)) {
             this.weight = weight;
         } else {
-            throw new IllegalArgumentException("Weight cannot be negative or zero");
+            throw new IllegalArgumentException("Weight must be between " + this.getMin() + " and " + this.getMax());
         }
     }
 
     private boolean validateWeight(int weight) {
-        return (weight > 0);
+        return (weight >= getMin() && weight <= getMax());
+    }
+
+    public Integer[] getValuesArray() {
+        int arrayLength = this.getMax() - this.getMin() + 1;
+        Integer[] intArray = new Integer[arrayLength];
+        for (int i = 0; i < intArray.length; i++) {
+            intArray[i] = this.getMin() + i;
+        }
+        return intArray;
     }
 
     @Override