repositories
/
Persons_Comparator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement some compareTo() methods.
[Persons_Comparator.git]
/
src
/
Weight.java
diff --git
a/src/Weight.java
b/src/Weight.java
index b0264faa591187841e4345f0a94b00e0d9347f63..e79d1025a9e35977344ab5003e129df1aa88ff03 100644
(file)
--- a/
src/Weight.java
+++ b/
src/Weight.java
@@
-23,6
+23,10
@@
public class Weight implements Comparable<Weight> {
@Override
public int compareTo(Weight weight) {
@Override
public int compareTo(Weight weight) {
- return 0;
+ int distance = weight.weight - this.getWeight();
+ if (distance >= 0)
+ return distance;
+ else
+ return -distance;
}
}
}
}