Route override toString()

- Print length, names of streets
    Estimated time (Best case)
    and endpoints.
This commit is contained in:
HeshamTB 2020-11-27 06:04:29 +03:00
parent b214b279db
commit 5fde1eee7e
Signed by: Hesham
GPG Key ID: 74876157D199B09E
2 changed files with 16 additions and 0 deletions

View File

@ -315,6 +315,8 @@ public class MakkahCity {
},District.ALAZIZIYA, Mashier.MINA);
//******Mina Leave end
// for (Route r : stdRoutes)
// System.out.println(r.toString());
}
private static void fillBusesToList() {

View File

@ -42,6 +42,20 @@ public class Route {
return result;
}
public String toString() {
StringBuilder s = new StringBuilder();
s.append(super.toString())
.append("\n").append(String.format("%s:%s",getHotelArea().name(),getMashier().name()))
.append("\n")
.append("Length: ").append(getTotalLength())
.append("\n")
.append("Streets: ");
for (Street street : this.getStreets())
s.append(street.getName().name()).append(" ");
s.append("\nBest Time: ").append(getFastestTimeOfTravel(new Bus())).append("\n");
return s.toString();
}
public District getHotelArea() {
return hotelArea;
}