summaryrefslogtreecommitdiff
path: root/src/section-4
diff options
context:
space:
mode:
authormokha <mokha@cisco.com>2019-05-05 19:57:14 -0600
committermokha <mokha@cisco.com>2019-05-05 19:57:14 -0600
commit7b4cb6a2eef3a0fcde7e998832427c73599e4a0a (patch)
tree75acc7cd8f3bd8a087e909db182c9e18a66879a1 /src/section-4
parent99a28d2dba93642e89a62ecf905a3bd4f138318d (diff)
use the exact naming convention for directories described by instructor
Diffstat (limited to 'src/section-4')
-rw-r--r--src/section-4/BanffMarathonRunner.java51
-rw-r--r--src/section-4/BanffMarathonRunnerTest.java61
2 files changed, 0 insertions, 112 deletions
diff --git a/src/section-4/BanffMarathonRunner.java b/src/section-4/BanffMarathonRunner.java
deleted file mode 100644
index afc0472..0000000
--- a/src/section-4/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<String> winners = new ArrayList<String>();
-
- for (BanffMarathonRunner runner : runners)
- if (runner.time >= average) winners.add(runner.toString());
-
- return String.join(System.lineSeparator(), winners);
- }
-}
diff --git a/src/section-4/BanffMarathonRunnerTest.java b/src/section-4/BanffMarathonRunnerTest.java
deleted file mode 100644
index 4b04ae0..0000000
--- a/src/section-4/BanffMarathonRunnerTest.java
+++ /dev/null
@@ -1,61 +0,0 @@
-package ca.mokhan.assignment1;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class BanffMarathonRunnerTest extends TestCase {
- private BanffMarathonRunner john = new BanffMarathonRunner("John", "Lenthen", 243, 1);
- private BanffMarathonRunner kate = new BanffMarathonRunner("Kate", "Hen", 265, 8);
- private 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),
- this.john,
- 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),
- this.kate
- };
-
- public BanffMarathonRunnerTest(String testName) {
- super(testName);
- }
-
- public static Test suite() {
- return new TestSuite(BanffMarathonRunnerTest.class);
- }
-
- public void testGetFastestRunner() {
- assertEquals(this.john, BanffMarathonRunner.getFastestRunner(this.runners));
- }
-
- public void testGetSecondFastestRunner() {
- assertEquals(this.kate, BanffMarathonRunner.getSecondFastestRunner(this.runners));
- }
-
- public void testGetAverageTime() {
- assertEquals(321, BanffMarathonRunner.getAverageTime(this.runners));
- }
-
- public void testGetAboveAverageRunners() {
- String expected =
- String.join(
- System.lineSeparator(),
- "Elena 1",
- "Suzie 7",
- "Philip 9",
- "James 1",
- "Jane 1",
- "Emily 4",
- "Neda 3");
- assertEquals(expected, BanffMarathonRunner.getAboveAverageRunners(this.runners));
- }
-}