Commit ccbe674
Changed files (1)
src
src/Q10/TrainTimeTable.java
@@ -14,7 +14,9 @@ public class TrainTimeTable {
this.schedule = schedule;
}
- public void delay(String station, int minutes) {}
+ public void delay(String station, int minutes) {
+ System.out.println(String.format("Delay %s by %d minutes", station, minutes));
+ }
public void displaySchedule() {
this.displaySchedule(System.out);
@@ -53,7 +55,7 @@ public class TrainTimeTable {
if (selection == null) {
System.out.println();
System.out.println("Enter command (Show, Delay, Quit):");
- selection = in.next().toLowerCase();
+ selection = in.nextLine().toLowerCase();
}
if (selection.equals("quit")) return;
@@ -61,7 +63,13 @@ public class TrainTimeTable {
if (selection.equals("show")) {
schedule.displaySchedule(System.out);
} else {
- System.out.println("Delay schedule");
+ String[] tokens = selection.split(" ");
+
+ if (tokens.length == 3) {
+ schedule.delay(tokens[1], Integer.parseInt(tokens[2]));
+ } else {
+ System.out.println("Could not parse command");
+ }
}
selection = null;