Output:
- Add label for current minute output - Use "\b" instead of " " when clearing line Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
da001dc5cd
commit
35cda81a46
@ -32,12 +32,10 @@ public class MakkahCity {
|
|||||||
|
|
||||||
fillBusesToList();
|
fillBusesToList();
|
||||||
|
|
||||||
//Make Streets
|
|
||||||
makeStreets();
|
makeStreets();
|
||||||
|
|
||||||
addCivilVehicleNoise();
|
addCivilVehicleNoise();
|
||||||
|
|
||||||
//Make Routes
|
|
||||||
makeRoutes();
|
makeRoutes();
|
||||||
|
|
||||||
//Set Routes for Campaigns
|
//Set Routes for Campaigns
|
||||||
@ -49,7 +47,7 @@ public class MakkahCity {
|
|||||||
if (firstDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) == 0){
|
if (firstDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) == 0){
|
||||||
System.out.println("\n\n" + getStreetsReport());
|
System.out.println("\n\n" + getStreetsReport());
|
||||||
}
|
}
|
||||||
else System.out.printf("%s\r", currenttimeManager.getCurrentTime());
|
else System.out.printf("simulation time: %s\r", currenttimeManager.getCurrentTime());
|
||||||
//Start of Every half-hour
|
//Start of Every half-hour
|
||||||
if (firstDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) % 30 == 0){
|
if (firstDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) % 30 == 0){
|
||||||
|
|
||||||
@ -63,14 +61,7 @@ public class MakkahCity {
|
|||||||
&& firstDayTimeMan.getCurrentCalendar().get(Calendar.SECOND) == getRandom(0,59)){
|
&& firstDayTimeMan.getCurrentCalendar().get(Calendar.SECOND) == getRandom(0,59)){
|
||||||
|
|
||||||
}
|
}
|
||||||
//Clear civil cars from list
|
clearDoneCivilVehicles();
|
||||||
for (int i = 0; i < listOfVehicles.size();){
|
|
||||||
Vehicle vehicle = listOfVehicles.get(i);
|
|
||||||
if (!(vehicle instanceof Bus) && vehicle.isArrivedToDest())
|
|
||||||
listOfVehicles.remove(vehicle);
|
|
||||||
else i++;
|
|
||||||
|
|
||||||
}
|
|
||||||
for (Vehicle vehicle : listOfVehicles) {
|
for (Vehicle vehicle : listOfVehicles) {
|
||||||
Route route = vehicle.getRoute();
|
Route route = vehicle.getRoute();
|
||||||
double currentLocation = vehicle.getCurrentLocation();
|
double currentLocation = vehicle.getCurrentLocation();
|
||||||
@ -97,7 +88,7 @@ public class MakkahCity {
|
|||||||
}
|
}
|
||||||
//noise based on time of day (From PDate)
|
//noise based on time of day (From PDate)
|
||||||
firstDayTimeMan.step(Calendar.MINUTE, 1);
|
firstDayTimeMan.step(Calendar.MINUTE, 1);
|
||||||
for (int i = 0; i < 28; i++) System.out.print(" ");
|
for (int i = 0; i < 46; i++) System.out.print("\b");
|
||||||
}
|
}
|
||||||
//TODO make report
|
//TODO make report
|
||||||
currenttimeManager = lastDayTimeMan;
|
currenttimeManager = lastDayTimeMan;
|
||||||
@ -113,7 +104,7 @@ public class MakkahCity {
|
|||||||
//TODO: removed break here. now should schedule.
|
//TODO: removed break here. now should schedule.
|
||||||
System.out.println("\n\n" + getStreetsReport());
|
System.out.println("\n\n" + getStreetsReport());
|
||||||
}
|
}
|
||||||
else System.out.printf("%s\r", currenttimeManager.getCurrentTime());
|
else System.out.printf("simulation time: %s\r", currenttimeManager.getCurrentTime());
|
||||||
//Start of Every half-hour
|
//Start of Every half-hour
|
||||||
if (lastDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) % 30 == 0){
|
if (lastDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) % 30 == 0){
|
||||||
|
|
||||||
@ -127,7 +118,7 @@ public class MakkahCity {
|
|||||||
&& lastDayTimeMan.getCurrentCalendar().get(Calendar.SECOND) == getRandom(0,59)){
|
&& lastDayTimeMan.getCurrentCalendar().get(Calendar.SECOND) == getRandom(0,59)){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
clearDoneCivilVehicles();
|
||||||
for (Vehicle vehicle : listOfVehicles) {
|
for (Vehicle vehicle : listOfVehicles) {
|
||||||
Route route = vehicle.getRoute();
|
Route route = vehicle.getRoute();
|
||||||
double currentLocation = vehicle.getCurrentLocation();
|
double currentLocation = vehicle.getCurrentLocation();
|
||||||
@ -154,11 +145,22 @@ public class MakkahCity {
|
|||||||
}
|
}
|
||||||
//noise based on time of day (From PDate)
|
//noise based on time of day (From PDate)
|
||||||
lastDayTimeMan.step(Calendar.MINUTE, 1);
|
lastDayTimeMan.step(Calendar.MINUTE, 1);
|
||||||
for (int i = 0; i < 28; i++) System.out.print(" ");
|
for (int i = 0; i < 46; i++) System.out.print("\b");
|
||||||
}
|
}
|
||||||
//TODO: print final report
|
//TODO: print final report
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void clearDoneCivilVehicles() {
|
||||||
|
//Clear civil cars from list
|
||||||
|
for (int i = 0; i < listOfVehicles.size();){
|
||||||
|
Vehicle vehicle = listOfVehicles.get(i);
|
||||||
|
if (!(vehicle instanceof Bus) && vehicle.isArrivedToDest())
|
||||||
|
listOfVehicles.remove(vehicle);
|
||||||
|
else i++;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static void setRoutesForCampaigns(Mashier mashier) {
|
private static void setRoutesForCampaigns(Mashier mashier) {
|
||||||
for (Campaign camp : listOfCampaigns){
|
for (Campaign camp : listOfCampaigns){
|
||||||
camp.setRoute(getShortestRoute(camp, mashier));
|
camp.setRoute(getShortestRoute(camp, mashier));
|
||||||
@ -335,12 +337,12 @@ public class MakkahCity {
|
|||||||
if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfSedan = (int) (numOfSedan * 1.5);
|
if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfSedan = (int) (numOfSedan * 1.5);
|
||||||
for (int x = 0; x < numOfSedan; x++) {
|
for (int x = 0; x < numOfSedan; x++) {
|
||||||
Sedan car = new Sedan(getRandom(4, 5));
|
Sedan car = new Sedan(getRandom(4, 5));
|
||||||
double pointOfEntry = getRandom(0, street.getLength());
|
double pointOfEntry = getRandom(0, street.getLength());//TODO: consider getLength - x
|
||||||
if (street.capcityPoint(pointOfEntry, pointOfEntry+1500) < 1){
|
if (street.capcityPoint(pointOfEntry, pointOfEntry+1500) < 1){
|
||||||
listOfVehicles.add(car);
|
listOfVehicles.add(car);
|
||||||
car.setCurrentLocation(pointOfEntry);
|
car.setCurrentLocation(pointOfEntry);
|
||||||
car.setRoute(new Route(street));
|
car.setRoute(new Route(street));
|
||||||
car.setCurrentStreet(street);
|
//car.setCurrentStreet(street);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -356,7 +358,7 @@ public class MakkahCity {
|
|||||||
listOfVehicles.add(car);
|
listOfVehicles.add(car);
|
||||||
car.setCurrentLocation(pointOfEntry);
|
car.setCurrentLocation(pointOfEntry);
|
||||||
car.setRoute(new Route(street));
|
car.setRoute(new Route(street));
|
||||||
car.setCurrentStreet(street);
|
//car.setCurrentStreet(street);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,7 +373,7 @@ public class MakkahCity {
|
|||||||
listOfVehicles.add(car);
|
listOfVehicles.add(car);
|
||||||
car.setCurrentLocation(pointOfEntry);
|
car.setCurrentLocation(pointOfEntry);
|
||||||
car.setRoute(new Route(street));
|
car.setRoute(new Route(street));
|
||||||
car.setCurrentStreet(street);
|
//car.setCurrentStreet(street);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -498,7 +500,7 @@ public class MakkahCity {
|
|||||||
for (Campaign campaign : listOfCampaigns) {
|
for (Campaign campaign : listOfCampaigns) {
|
||||||
numberOfBusses += campaign.getNumberOfBusses();
|
numberOfBusses += campaign.getNumberOfBusses();
|
||||||
}
|
}
|
||||||
String s = String.format("Buses: %d Buses done: %d Average trip in last hour time: %s\n",
|
String s = String.format("Buses: %d Buses done: %d Average trip in last hour: %s\n",
|
||||||
numberOfBusses, numberOfArrivedBuses, avgTimeOfTrip());
|
numberOfBusses, numberOfArrivedBuses, avgTimeOfTrip());
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user