supplemented train info with start/stop stations

This commit is contained in:
steven@devbox 2025-07-20 04:00:40 +00:00
commit fae4b5870e

View file

@ -54,6 +54,14 @@ public class App {
this.arrivalTime = arrivalTime; this.arrivalTime = arrivalTime;
this.stops = stops.clone(); this.stops = stops.clone();
} }
public Station getStartStation() {
return this.stops[0];
}
public Station getFinalStation() {
return this.stops[this.stops.length - 1];
}
} }
class LineData { class LineData {
@ -183,7 +191,8 @@ public class App {
String toStationName = sc.nextLine(); String toStationName = sc.nextLine();
ArrayList<Train> trains2 = a.trainsFromTo(fromStationName, toStationName); ArrayList<Train> trains2 = a.trainsFromTo(fromStationName, toStationName);
for (Train t : trains2) { for (Train t : trains2) {
System.out.println("found " + t.type.toString()); System.out.println("found " + t.type.toString() + " from " + t.getStartStation().getName() + " to "
+ t.getFinalStation().getName());
} }
sc.close(); sc.close();
} }