From 3c2be35d16d7482442911f5b06b68512f86e15b5 Mon Sep 17 00:00:00 2001 From: mokha Date: Sun, 5 May 2019 19:36:09 -0600 Subject: butcher default directory structure to make instructor happy --- .../ca/mokhan/assignment1/BanffMarathonRunner.java | 51 ---------------------- 1 file changed, 51 deletions(-) delete mode 100644 src/main/java/ca/mokhan/assignment1/BanffMarathonRunner.java (limited to 'src/main/java/ca/mokhan/assignment1/BanffMarathonRunner.java') diff --git a/src/main/java/ca/mokhan/assignment1/BanffMarathonRunner.java b/src/main/java/ca/mokhan/assignment1/BanffMarathonRunner.java deleted file mode 100644 index afc0472..0000000 --- a/src/main/java/ca/mokhan/assignment1/BanffMarathonRunner.java +++ /dev/null @@ -1,51 +0,0 @@ -package ca.mokhan.assignment1; - -import java.util.ArrayList; -import java.util.Arrays; - -public class BanffMarathonRunner extends AddressBook { - private int time; - private int years; - - public BanffMarathonRunner(String firstName, String lastName, int time, int years) { - super(firstName, "", lastName); - this.time = time; - this.years = years; - } - - public int compareTo(AddressBook other) { - BanffMarathonRunner runner = (BanffMarathonRunner) other; - return Integer.compare(this.time, runner.time); - } - - @Override - public String toString() { - return super.getFirstName() + " " + this.years; - } - - public static BanffMarathonRunner getFastestRunner(BanffMarathonRunner[] runners) { - Arrays.sort(runners); - return runners[0]; - } - - public static BanffMarathonRunner getSecondFastestRunner(BanffMarathonRunner[] runners) { - Arrays.sort(runners); - return runners[1]; - } - - public static int getAverageTime(BanffMarathonRunner[] runners) { - int sum = 0; - for (BanffMarathonRunner runner : runners) sum += runner.time; - return sum / runners.length; - } - - public static String getAboveAverageRunners(BanffMarathonRunner[] runners) { - int average = getAverageTime(runners); - ArrayList winners = new ArrayList(); - - for (BanffMarathonRunner runner : runners) - if (runner.time >= average) winners.add(runner.toString()); - - return String.join(System.lineSeparator(), winners); - } -} -- cgit v1.2.3