X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2FWeight.java;h=47547ba4f524711c42a3bc1c3e561fec0be48853;hb=b974e749af3a4b2df3737b2d361233c704dcc4d8;hp=b0264faa591187841e4345f0a94b00e0d9347f63;hpb=1c1189337121a1baa74961813e619c99b398a333;p=Persons_Comparator.git diff --git a/src/Weight.java b/src/Weight.java index b0264fa..47547ba 100644 --- a/src/Weight.java +++ b/src/Weight.java @@ -1,6 +1,9 @@ public class Weight implements Comparable { private int weight; + Weight() { + } + Weight(int weight) { setWeight(weight); } @@ -23,6 +26,10 @@ public class Weight implements Comparable { @Override public int compareTo(Weight weight) { - return 0; + int distance = weight.weight - this.getWeight(); + if (distance >= 0) + return distance; + else + return -distance; } }