From 5e94dc5f40f8f96496946b0a203a6d670de50418 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Tue, 4 Oct 2022 12:54:21 +0200 Subject: [PATCH] solved Task 1 --- src/ch/zhaw/ads/Competitor.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ch/zhaw/ads/Competitor.java b/src/ch/zhaw/ads/Competitor.java index d3af624..9ebe5a7 100644 --- a/src/ch/zhaw/ads/Competitor.java +++ b/src/ch/zhaw/ads/Competitor.java @@ -49,19 +49,25 @@ public class Competitor implements Comparable { @Override public int compareTo(Competitor o) { // TODO Implement - return 0; + Competitor o2 = (Competitor)o; + return (int) (this.parseTime(time) - o.parseTime(o2.getTime())); } @Override public boolean equals (Object o) { // TODO Implement + if(o instanceof Competitor){ + Competitor o2 = (Competitor)o; + return compareTo(o2) == 0; + } return false; } @Override public int hashCode() { // TODO Implement - return 0; + int result = 17; + return result * (int)parseTime(time); } }