Vehicle toString()
Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
2edf82b28b
commit
d7e3fd7a68
@ -185,10 +185,7 @@ public class MakkahCity {
|
||||
String c = in.next();
|
||||
Vehicle v = listOfVehicles.get(Integer.parseInt(c));
|
||||
//TODO: override toString() in vehicle then Bus. This will throw cast ex.
|
||||
System.out.printf("%s\n Campaign: %s Street: %s Location: %.1f\n" +
|
||||
"Arrived: %s Starting time: %s Arrive Time: %s\n",
|
||||
v.toString(), ((Bus)v).getCampaign().getUID(),v.getCurrentStreet().getName().name(),
|
||||
v.getCurrentLocation(),v.isArrivedToDest(),v.getTimeStartedMoving(),v.getTimeOfArrival());
|
||||
System.out.print(v.toString());
|
||||
}
|
||||
if (choice.equals("2")){
|
||||
for (int i = 0; i < stdStreet.length; i++) {
|
||||
|
@ -166,7 +166,14 @@ public abstract class Vehicle {
|
||||
public boolean hasCrossedStreet(Street street) {
|
||||
return routeTimeHistory.containsKey(street);
|
||||
}
|
||||
|
||||
|
||||
public String toString() {
|
||||
return String.format("%s\nStreet: %s Location: %.1f\n" +
|
||||
"Arrived: %s Starting time: %s Arrive Time: %s\n",
|
||||
super.toString(), this.getCurrentStreet().getName().name(),
|
||||
this.getCurrentLocation(), this.isArrivedToDest(),
|
||||
this.getTimeStartedMoving(), this.getTimeOfArrival());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user