Throw an error for illegal arguments.
authorJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 8 Jan 2019 13:42:35 +0000 (14:42 +0100)
committerJérôme Benoit <jerome.benoit@piment-noir.org>
Tue, 8 Jan 2019 13:42:35 +0000 (14:42 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@piment-noir.org>
src/Size.java
src/Weight.java

index 0cecada6c98192f7cfa94f874f937e1fe9831276..dfea96cdd8226c8dba12b50fa86423ceb2635658 100644 (file)
@@ -15,7 +15,9 @@ public class Size {
     public void setSize(int size) {
         if (validateSize(size)) {
             this.size = size;
-        } /* FIXME: raise an error */
+        } else {
+            throw new IllegalArgumentException("Size must be between" + this.min + " and " + this.max);
+        }
     }
 
     private boolean validateSize(int size) {
index 3f2a829163130f8bba5c5ed1e22e5fdd0fa916c3..2a8c8127d7cb17f63cbe5aa8e6a98a26209a3f24 100644 (file)
@@ -12,7 +12,9 @@ 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) {