diff options
| author | mo khan <mo@mokhan.ca> | 2019-08-05 18:31:16 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2019-08-05 18:31:16 -0600 |
| commit | a70558eb11c09c510897032a04143a79e7dd72a9 (patch) | |
| tree | f34f8dbdc6a3d4342a4c297284de3e3ac5c7b932 | |
| parent | 155585dd1c618d1758af87cb27902429bef91f53 (diff) | |
format the output for Q10
| -rw-r--r-- | src/Q10/TrainTimeTable.java | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/Q10/TrainTimeTable.java b/src/Q10/TrainTimeTable.java index 36e4294..52992e4 100644 --- a/src/Q10/TrainTimeTable.java +++ b/src/Q10/TrainTimeTable.java @@ -15,11 +15,6 @@ public class TrainTimeTable { } public void delay(String city, int minutes) { - System.out.println(); - System.out.println(city); - System.out.println(String.format("Delay %s by %d minutes", city, minutes)); - System.out.println(); - Station station = stationIn(city); if (station != null) { station.delayBy(minutes); @@ -34,12 +29,12 @@ public class TrainTimeTable { } public void displaySchedule(PrintStream out) { - out.println("Station | Arrival | Departure | Day"); + out.println(String.format("%15s | %7s | %9s | %3s", "Station", "Arrival", "Departure", "Day")); for (Station station : schedule) out.println( String.format( - "%s | %s | %s | %d", + "%15s | %7s | %9s | %3d", station.getCity(), station.getArrival(), station.getDeparture(), station.getDay())); } @@ -83,16 +78,10 @@ public class TrainTimeTable { } else { String[] tokens = selection.split(" "); - if (tokens.length < 3) { - System.out.println("Could not parse command"); - continue; - } + if (tokens.length < 3) continue; String city = ""; - for (int i = 1; i < tokens.length - 1; i++) { - System.out.println(tokens[i]); - city += tokens[i]; - } + for (int i = 1; i < tokens.length - 1; i++) city += tokens[i]; schedule.delay(city, Integer.parseInt(tokens[tokens.length - 1])); } |
