Commit f1f1f63
Changed files (2)
src/Q10/TrainTimeTable.java
@@ -32,6 +32,10 @@ public class TrainTimeTable {
station.getCity(), station.getArrival(), station.getDeparture(), station.getDay()));
}
+ public Station stationIn(String city) {
+ return null;
+ }
+
public static void main(String[] args) {
System.out.println("=== Question 10 ===");
LinkedList<Station> stations = new LinkedList<Station>();
src/Q10/TrainTimeTableTest.java
@@ -0,0 +1,46 @@
+package ca.mokhan.test;
+
+import Q10.*;
+import java.io.*;
+import java.text.*;
+import java.util.*;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class TrainTimeTableTest extends TestCase {
+ private TrainTimeTable subject;
+ private LinkedList<Station> stations =
+ new LinkedList<Station>(
+ Arrays.asList(
+ new Station("Vancouver", null, new Date(), 1),
+ new Station("Kamloops", new Date(), new Date(), 2),
+ new Station("Jasper", new Date(), new Date(), 2),
+ new Station("Edmonton", new Date(), new Date(), 2),
+ new Station("Saskatchewan", new Date(), new Date(), 3),
+ new Station("Winnipeg", new Date(), new Date(), 3),
+ new Station("Sioux Lookout", new Date(), new Date(), 4),
+ new Station("Hornepayne", new Date(), new Date(), 4),
+ new Station("Capreol", new Date(), new Date(), 5),
+ new Station("Toronto", new Date(), new Date(), 5)));
+
+ public TrainTimeTableTest(String testName) {
+ super(testName);
+ this.subject = new TrainTimeTable(this.stations);
+ }
+
+ public static Test suite() {
+ return new TestSuite(TrainTimeTableTest.class);
+ }
+
+ public void test_delay_edmonton_30minutes() {
+ this.subject.delay("Edmonton", 30);
+
+ Station station = this.subject.stationIn("Edmonton");
+ assertNotNull(station);
+ assertEquals("Edmonton", station.getCity());
+ assertEquals("23:30", station.getArrival());
+ assertEquals("00:29", station.getDeparture());
+ assertEquals(3, station.getDay());
+ }
+}