-public class Weight {
+public class Weight implements Comparable<Weight> {
private int weight;
Weight(int 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;
+ }
}