From 29adffee18384945e362163f75a2796fb07d0f91 Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Tue, 4 Oct 2022 14:36:37 +0200 Subject: [PATCH] Solve the first exercise --- .../main/java/ch/nuth/zhaw/exbox/Competitor.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/ch/nuth/zhaw/exbox/Competitor.java b/app/src/main/java/ch/nuth/zhaw/exbox/Competitor.java index 03b4d3a..84b79f7 100644 --- a/app/src/main/java/ch/nuth/zhaw/exbox/Competitor.java +++ b/app/src/main/java/ch/nuth/zhaw/exbox/Competitor.java @@ -48,20 +48,23 @@ public class Competitor implements Comparable { @Override public int compareTo(Competitor o) { - // TODO Implement - return 0; + return Long.compare(parseTime(getTime()), parseTime(o.getTime())); } @Override public boolean equals (Object o) { - // TODO Implement - return false; + if (o instanceof Competitor) { + Competitor c = (Competitor)o; + return compareTo(c) == 0; + } + else { + return false; + } } @Override public int hashCode() { - // TODO Implement - return 0; + return (getTime().hashCode() + getName().hashCode()) * rank; } }