-public class Weight {
+public class Weight implements Comparable<Weight> {
private int weight;
Weight(int weight) {
private boolean validateWeight(int weight) {
return (weight > 0);
}
+
+ @Override
+ public int compareTo(Weight weight) {
+ int distance = weight.weight - this.getWeight();
+ if (distance >= 0)
+ return distance;
+ else
+ return -distance;
+ }
}