summaryrefslogtreecommitdiff
path: root/src/Q4
diff options
context:
space:
mode:
authormokha <mokha@cisco.com>2019-05-14 21:58:17 -0600
committermokha <mokha@cisco.com>2019-05-14 21:58:17 -0600
commitc3a480ef258a2c6f73e1ac66c9cb97d79ffa7df9 (patch)
tree33b8302645f3194f9f08b017fbe41a39a86c18dc /src/Q4
parent2ecd84e4026c9438405ca7dec61158291214cedb (diff)
add console app for Q4
Diffstat (limited to 'src/Q4')
-rw-r--r--src/Q4/BanffMarathonRunner.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/Q4/BanffMarathonRunner.java b/src/Q4/BanffMarathonRunner.java
index e1598fa..292d5b5 100644
--- a/src/Q4/BanffMarathonRunner.java
+++ b/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;
@@ -45,6 +46,15 @@ public class BanffMarathonRunner extends AddressBook {
}
/**
+ * 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.
*
* @return The first name + the # of years that they participated.
@@ -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));
+ }
}