Commit c3a480e
Changed files (1)
src
src/Q4/BanffMarathonRunner.java
@@ -11,6 +11,7 @@ package Q4;
import Q1.*;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Scanner;
public class BanffMarathonRunner extends AddressBook {
private int time;
@@ -44,6 +45,15 @@ public class BanffMarathonRunner extends AddressBook {
return Integer.compare(this.time, runner.time);
}
+ /**
+ * Return the time take to complete the race.
+ *
+ * @return the time taken to complete the race
+ */
+ public int getTime() {
+ return this.time;
+ }
+
/**
* Returns a string representation of the runner.
*
@@ -103,4 +113,37 @@ public class BanffMarathonRunner extends AddressBook {
return String.join(System.lineSeparator(), winners);
}
+
+ public static void main(String[] args) {
+ BanffMarathonRunner[] runners = {
+ new BanffMarathonRunner("Elena", "Brandon", 341, 1),
+ new BanffMarathonRunner("Thomas", "Molson", 273, 2),
+ new BanffMarathonRunner("Hamilton", "Winn", 278, 5),
+ new BanffMarathonRunner("Suzie", "Sarandin", 329, 7),
+ new BanffMarathonRunner("Philip", "Winne", 445, 9),
+ new BanffMarathonRunner("Alex", "Trebok", 275, 3),
+ new BanffMarathonRunner("Emma", "Pivoto", 275, 4),
+ new BanffMarathonRunner("John", "Lenthen", 243, 1),
+ new BanffMarathonRunner("James", "Lean", 334, 1),
+ new BanffMarathonRunner("Jane", "Ostin", 412, 1),
+ new BanffMarathonRunner("Emily", "Car", 393, 4),
+ new BanffMarathonRunner("Daniel", "Hamshire", 299, 4),
+ new BanffMarathonRunner("Neda", "Bazdar", 343, 3),
+ new BanffMarathonRunner("Aaron", "Smith", 317, 6),
+ new BanffMarathonRunner("Kate", "Hen", 265, 8)
+ };
+
+ BanffMarathonRunner fastestRunner = BanffMarathonRunner.getFastestRunner(runners);
+ System.out.println(fastestRunner.getFirstName());
+ System.out.println(fastestRunner.getHomeAddress());
+ System.out.println(fastestRunner.getTime());
+
+ BanffMarathonRunner secondFastestRunner = BanffMarathonRunner.getSecondFastestRunner(runners);
+ System.out.println(secondFastestRunner.getFirstName());
+ System.out.println(secondFastestRunner.getHomeAddress());
+ System.out.println(secondFastestRunner.getTime());
+ System.out.println(secondFastestRunner.getTime() - fastestRunner.getTime());
+
+ System.out.print(BanffMarathonRunner.getAboveAverageRunners(runners));
+ }
}