solved Task 2

This commit is contained in:
schrom01 2022-11-15 13:27:25 +01:00
parent 69fb83dd74
commit 15e14023db
1 changed files with 8 additions and 3 deletions

View File

@ -48,18 +48,23 @@ public class MyCompetitor implements Comparable<MyCompetitor> {
@Override
public int compareTo(MyCompetitor o) {
// to be done
return -1;
int rankDiff = rank - o.rank;
int nameDiff = name.compareTo(o.name);
return 10000 * rankDiff + nameDiff;
}
@Override
public int hashCode() {
// to be done
return -1;
return rank % 3500 + name.hashCode() ;
}
@Override
public boolean equals (Object o) {
// to be done
if(! (o instanceof MyCompetitor)){
return false;
}
return compareTo((MyCompetitor) o) == 0;
}
}