|
|
@ -17,8 +17,8 @@ public class MakkahCity {
|
|
|
|
private static Date allArrivedToHotelsTime;
|
|
|
|
private static Date allArrivedToHotelsTime;
|
|
|
|
|
|
|
|
|
|
|
|
private static final PDate firstDayTimeMan = new PDate(
|
|
|
|
private static final PDate firstDayTimeMan = new PDate(
|
|
|
|
new GregorianCalendar(1442, Calendar.JANUARY, 9, 4, 0, 0),
|
|
|
|
new GregorianCalendar(1442, Calendar.JANUARY, 9, 4, 0, 0),
|
|
|
|
new GregorianCalendar(1442, Calendar.JANUARY, 9, 18, 0, 0)
|
|
|
|
new GregorianCalendar(1442, Calendar.JANUARY, 9, 18, 0, 0)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
private static final PDate lastDayTimeMan = new PDate(
|
|
|
|
private static final PDate lastDayTimeMan = new PDate(
|
|
|
@ -46,9 +46,9 @@ public class MakkahCity {
|
|
|
|
private static JLabel lblNumOfDonebuses;
|
|
|
|
private static JLabel lblNumOfDonebuses;
|
|
|
|
private static JLabel lblMaximumTripValue;
|
|
|
|
private static JLabel lblMaximumTripValue;
|
|
|
|
private static JLabel lblMinimumTripValue;
|
|
|
|
private static JLabel lblMinimumTripValue;
|
|
|
|
private static JLabel lblBusesArrivedInTheLastHourValue;
|
|
|
|
private static JLabel lblBusesArrivedInTheLastHourValue;
|
|
|
|
private static JLabel lblAverageTripForLastHourValue;
|
|
|
|
private static JLabel lblAverageTripForLastHourValue;
|
|
|
|
private static JButton btnPause;
|
|
|
|
private static JButton btnPause;
|
|
|
|
private static JLabel lblAverageTimeForTheTrip;
|
|
|
|
private static JLabel lblAverageTimeForTheTrip;
|
|
|
|
private static JLabel lblArrivedToArafatTime;
|
|
|
|
private static JLabel lblArrivedToArafatTime;
|
|
|
|
private static JLabel lblArrivedToHotelsTime;
|
|
|
|
private static JLabel lblArrivedToHotelsTime;
|
|
|
@ -56,7 +56,6 @@ public class MakkahCity {
|
|
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
|
|
|
|
|
|
//TODO: fix state errors
|
|
|
|
|
|
|
|
t.start();
|
|
|
|
t.start();
|
|
|
|
//Gen Camp
|
|
|
|
//Gen Camp
|
|
|
|
campPerDistrict[District.ALMANSOOR.ordinal()] = new ArrayList<>();
|
|
|
|
campPerDistrict[District.ALMANSOOR.ordinal()] = new ArrayList<>();
|
|
|
@ -439,16 +438,16 @@ public class MakkahCity {
|
|
|
|
clearDoneCivilVehicles();
|
|
|
|
clearDoneCivilVehicles();
|
|
|
|
addCivilVehicleNoise();
|
|
|
|
addCivilVehicleNoise();
|
|
|
|
for (Vehicle vehicle : listOfVehicles) {
|
|
|
|
for (Vehicle vehicle : listOfVehicles) {
|
|
|
|
if (vehicle.getRoute() == null)
|
|
|
|
if (vehicle.getRoute() == null || vehicle.isArrivedToDest())
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
Route route = vehicle.getRoute();
|
|
|
|
Route route = vehicle.getRoute();
|
|
|
|
double currentLocation = vehicle.getCurrentLocation();
|
|
|
|
double currentLocation = vehicle.getCurrentLocation();
|
|
|
|
if (vehicle.getCurrentStreet() == null &&
|
|
|
|
if (vehicle.getCurrentStreet() == null &&
|
|
|
|
firstDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) % 2 == 0 &&
|
|
|
|
firstDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) % 2 == 0 &&
|
|
|
|
route.getStreets()[0].capcityPoint(0,1000) < 1) {
|
|
|
|
route.getStreets()[0].capcityPoint(0,1000) < 1) {
|
|
|
|
vehicle.setCurrentStreet(route.getStreets()[0]);
|
|
|
|
vehicle.setCurrentStreet(route.getStreets()[0]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (vehicle.getCurrentStreet() != null && vehicle.getCurrentStreet().capcityPoint(currentLocation,
|
|
|
|
if (vehicle.getCurrentStreet() != null && vehicle.getCurrentStreet().capcityPoint(currentLocation,
|
|
|
|
currentLocation+1000) < 1 ) {
|
|
|
|
currentLocation+1000) < 1 ) {
|
|
|
|
|
|
|
|
|
|
|
|
if (currentLocation >= vehicle.getCurrentStreet().getLength()) {
|
|
|
|
if (currentLocation >= vehicle.getCurrentStreet().getLength()) {
|
|
|
@ -457,11 +456,8 @@ public class MakkahCity {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!vehicle.isArrivedToDest()) {
|
|
|
|
if (!vehicle.isArrivedToDest()) {
|
|
|
|
double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(),
|
|
|
|
double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(),
|
|
|
|
vehicle.getCurrentLocation()+1000,vehicle)) ;
|
|
|
|
vehicle.getCurrentLocation()+1000,vehicle)) ;
|
|
|
|
if (vehicle instanceof Bus) vehicle.move(Bus.MAX_FORWARD * factor );
|
|
|
|
vehicle.move(vehicle.getMaxSpeed()*factor);
|
|
|
|
else if (vehicle instanceof Sedan) vehicle.move(Sedan.MAX_FORWARD * factor );
|
|
|
|
|
|
|
|
else if (vehicle instanceof SUV) vehicle.move(SUV.MAX_FORWARD * factor );
|
|
|
|
|
|
|
|
else if (vehicle instanceof Truck) vehicle.move(Bus.MAX_FORWARD * factor );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -503,7 +499,7 @@ public class MakkahCity {
|
|
|
|
clearDoneCivilVehicles();
|
|
|
|
clearDoneCivilVehicles();
|
|
|
|
addCivilVehicleNoise();
|
|
|
|
addCivilVehicleNoise();
|
|
|
|
for (Vehicle vehicle : listOfVehicles) {
|
|
|
|
for (Vehicle vehicle : listOfVehicles) {
|
|
|
|
if (vehicle.getRoute() == null)
|
|
|
|
if (vehicle.getRoute() == null || vehicle.isArrivedToDest())
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
Route route = vehicle.getRoute();
|
|
|
|
Route route = vehicle.getRoute();
|
|
|
|
double currentLocation = vehicle.getCurrentLocation();
|
|
|
|
double currentLocation = vehicle.getCurrentLocation();
|
|
|
@ -521,10 +517,7 @@ public class MakkahCity {
|
|
|
|
if (!vehicle.isArrivedToDest()) {
|
|
|
|
if (!vehicle.isArrivedToDest()) {
|
|
|
|
double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(),
|
|
|
|
double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(),
|
|
|
|
vehicle.getCurrentLocation()+1000,vehicle)) ;
|
|
|
|
vehicle.getCurrentLocation()+1000,vehicle)) ;
|
|
|
|
if (vehicle instanceof Bus) vehicle.move(Bus.MAX_FORWARD * factor );
|
|
|
|
vehicle.move(vehicle.getMaxSpeed()* factor);
|
|
|
|
else if (vehicle instanceof Sedan) vehicle.move(Sedan.MAX_FORWARD * factor );
|
|
|
|
|
|
|
|
else if (vehicle instanceof SUV) vehicle.move(SUV.MAX_FORWARD * factor );
|
|
|
|
|
|
|
|
else if (vehicle instanceof Truck) vehicle.move(Bus.MAX_FORWARD * factor );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -565,15 +558,15 @@ public class MakkahCity {
|
|
|
|
private static void startMenu() {
|
|
|
|
private static void startMenu() {
|
|
|
|
Scanner in = new Scanner(System.in);
|
|
|
|
Scanner in = new Scanner(System.in);
|
|
|
|
System.out.println("\n"+currenttimeManager.getCurrentTime()+"\n"+
|
|
|
|
System.out.println("\n"+currenttimeManager.getCurrentTime()+"\n"+
|
|
|
|
"---------------------------\n" +
|
|
|
|
"---------------------------\n" +
|
|
|
|
"[1] View Buses\n" +
|
|
|
|
"[1] View Buses\n" +
|
|
|
|
"[2] View Streets\n" +
|
|
|
|
"[2] View Streets\n" +
|
|
|
|
"[3] View Campaigns\n" +
|
|
|
|
"[3] View Campaigns\n" +
|
|
|
|
"[4] View Routes\n" +
|
|
|
|
"[4] View Routes\n" +
|
|
|
|
"[5] Print report\n" +
|
|
|
|
"[5] Print report\n" +
|
|
|
|
"[6] Browse History\n" +
|
|
|
|
"[6] Browse History\n" +
|
|
|
|
"[7] Continue\n" +
|
|
|
|
"[7] Continue\n" +
|
|
|
|
"[8] Exit");
|
|
|
|
"[8] Exit");
|
|
|
|
String choice = in.next();
|
|
|
|
String choice = in.next();
|
|
|
|
//Split into methods?
|
|
|
|
//Split into methods?
|
|
|
|
if (choice.equals("1")){
|
|
|
|
if (choice.equals("1")){
|
|
|
@ -592,7 +585,7 @@ public class MakkahCity {
|
|
|
|
stdStreet[i].getPercentRemainingCapacity());
|
|
|
|
stdStreet[i].getPercentRemainingCapacity());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String input = in.next();
|
|
|
|
String input = in.next();
|
|
|
|
int index = Integer.parseInt(input);//TODO: unhandled ex
|
|
|
|
int index = Integer.parseInt(input);
|
|
|
|
showStreet(stdStreet[index]);
|
|
|
|
showStreet(stdStreet[index]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (choice.equals("4")){
|
|
|
|
if (choice.equals("4")){
|
|
|
@ -695,9 +688,9 @@ public class MakkahCity {
|
|
|
|
while (!selected){
|
|
|
|
while (!selected){
|
|
|
|
System.out.println(new HijriDate(dummyCal.getTimeInMillis()));
|
|
|
|
System.out.println(new HijriDate(dummyCal.getTimeInMillis()));
|
|
|
|
System.out.print("[1] Forward\n" +
|
|
|
|
System.out.print("[1] Forward\n" +
|
|
|
|
"[2] Backward\n" +
|
|
|
|
"[2] Backward\n" +
|
|
|
|
"[3] Select\n" +
|
|
|
|
"[3] Select\n" +
|
|
|
|
"[4] Return\n");
|
|
|
|
"[4] Return\n");
|
|
|
|
String choice = in.next();
|
|
|
|
String choice = in.next();
|
|
|
|
if (choice.equals("1")) dummyCal.roll(Calendar.HOUR, 1);
|
|
|
|
if (choice.equals("1")) dummyCal.roll(Calendar.HOUR, 1);
|
|
|
|
if (choice.equals("2")) dummyCal.roll(Calendar.HOUR, -1);
|
|
|
|
if (choice.equals("2")) dummyCal.roll(Calendar.HOUR, -1);
|
|
|
@ -784,9 +777,9 @@ public class MakkahCity {
|
|
|
|
District.ALHIJRA, Mashier.ARAFAT);
|
|
|
|
District.ALHIJRA, Mashier.ARAFAT);
|
|
|
|
|
|
|
|
|
|
|
|
stdRoutes[RouteName.AlHijraToArafat2.ordinal()] = new Route(new Street[]{
|
|
|
|
stdRoutes[RouteName.AlHijraToArafat2.ordinal()] = new Route(new Street[]{
|
|
|
|
stdStreet[StreetNames.JABAL_THAWR_STREET.ordinal()],
|
|
|
|
stdStreet[StreetNames.JABAL_THAWR_STREET.ordinal()],
|
|
|
|
stdStreet[StreetNames.FOURTH_HIGHWAY2.ordinal()],
|
|
|
|
stdStreet[StreetNames.FOURTH_HIGHWAY2.ordinal()],
|
|
|
|
stdStreet[StreetNames.STREET1.ordinal()]
|
|
|
|
stdStreet[StreetNames.STREET1.ordinal()]
|
|
|
|
},District.ALHIJRA, Mashier.ARAFAT);
|
|
|
|
},District.ALHIJRA, Mashier.ARAFAT);
|
|
|
|
|
|
|
|
|
|
|
|
stdRoutes[RouteName.AlMansoorToArafat1.ordinal()] = new Route(
|
|
|
|
stdRoutes[RouteName.AlMansoorToArafat1.ordinal()] = new Route(
|
|
|
@ -820,7 +813,7 @@ public class MakkahCity {
|
|
|
|
stdStreet[StreetNames.KA_STREET.ordinal()],
|
|
|
|
stdStreet[StreetNames.KA_STREET.ordinal()],
|
|
|
|
stdStreet[StreetNames.STREET2.ordinal()],
|
|
|
|
stdStreet[StreetNames.STREET2.ordinal()],
|
|
|
|
stdStreet[StreetNames.STREET1.ordinal()]
|
|
|
|
stdStreet[StreetNames.STREET1.ordinal()]
|
|
|
|
},District.ALAZIZIYA, Mashier.ARAFAT);
|
|
|
|
},District.ALAZIZIYA, Mashier.ARAFAT);
|
|
|
|
|
|
|
|
|
|
|
|
//******Arafat day end
|
|
|
|
//******Arafat day end
|
|
|
|
|
|
|
|
|
|
|
@ -911,7 +904,7 @@ public class MakkahCity {
|
|
|
|
if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfSedan = (int) (numOfSedan * 1.2);
|
|
|
|
if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfSedan = (int) (numOfSedan * 1.2);
|
|
|
|
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());//TODO: consider getLength - x
|
|
|
|
double pointOfEntry = getRandom(0, street.getLength());
|
|
|
|
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);
|
|
|
@ -924,7 +917,7 @@ public class MakkahCity {
|
|
|
|
if (street.getName() == StreetNames.FOURTH_HIGHWAY1) numOfTruck = (int) (numOfTruck * 0.5);
|
|
|
|
if (street.getName() == StreetNames.FOURTH_HIGHWAY1) numOfTruck = (int) (numOfTruck * 0.5);
|
|
|
|
if (street.getName() == StreetNames.FOURTH_HIGHWAY2) numOfTruck = (int) (numOfTruck * 0.5);
|
|
|
|
if (street.getName() == StreetNames.FOURTH_HIGHWAY2) numOfTruck = (int) (numOfTruck * 0.5);
|
|
|
|
if (street.getName() == StreetNames.STREET3) numOfTruck = (int) (numOfTruck * 1.5);
|
|
|
|
if (street.getName() == StreetNames.STREET3) numOfTruck = (int) (numOfTruck * 1.5);
|
|
|
|
if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfSedan = (int) (numOfSedan * 1.2);
|
|
|
|
if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfTruck = (int) (numOfTruck * 1.2);
|
|
|
|
for (int x = 0; x < numOfTruck; x++) {
|
|
|
|
for (int x = 0; x < numOfTruck; x++) {
|
|
|
|
Truck car = new Truck(getRandom(4, 5));
|
|
|
|
Truck car = new Truck(getRandom(4, 5));
|
|
|
|
double pointOfEntry = getRandom(0, street.getLength());
|
|
|
|
double pointOfEntry = getRandom(0, street.getLength());
|
|
|
@ -939,7 +932,7 @@ public class MakkahCity {
|
|
|
|
if (street.getName() == StreetNames.FOURTH_HIGHWAY1) numOfSUV = (int) (numOfSUV * 0.5);
|
|
|
|
if (street.getName() == StreetNames.FOURTH_HIGHWAY1) numOfSUV = (int) (numOfSUV * 0.5);
|
|
|
|
if (street.getName() == StreetNames.FOURTH_HIGHWAY2) numOfSUV = (int) (numOfSUV * 0.5);
|
|
|
|
if (street.getName() == StreetNames.FOURTH_HIGHWAY2) numOfSUV = (int) (numOfSUV * 0.5);
|
|
|
|
if (street.getName() == StreetNames.STREET3) numOfSUV = (int) (numOfSUV * 1.5);
|
|
|
|
if (street.getName() == StreetNames.STREET3) numOfSUV = (int) (numOfSUV * 1.5);
|
|
|
|
if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfSUV = (int) (numOfSedan * 1.2);
|
|
|
|
if (street.getName() == StreetNames.IBRAHIM_ALKHALIL2) numOfSUV = (int) (numOfSUV * 1.2);
|
|
|
|
for (int x = 0; x < numOfSUV; x++) {
|
|
|
|
for (int x = 0; x < numOfSUV; x++) {
|
|
|
|
SUV car = new SUV(getRandom(4, 5));
|
|
|
|
SUV car = new SUV(getRandom(4, 5));
|
|
|
|
double pointOfEntry = getRandom(0, street.getLength());
|
|
|
|
double pointOfEntry = getRandom(0, street.getLength());
|
|
|
@ -950,7 +943,6 @@ public class MakkahCity {
|
|
|
|
car.setCurrentStreet(street);
|
|
|
|
car.setCurrentStreet(street);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -958,12 +950,6 @@ public class MakkahCity {
|
|
|
|
return currenttimeManager;
|
|
|
|
return currenttimeManager;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Find shortest path without respect to traffic
|
|
|
|
|
|
|
|
* @param campaign
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Route getBestRoute(Campaign campaign , Mashier mashier) {
|
|
|
|
private static Route getBestRoute(Campaign campaign , Mashier mashier) {
|
|
|
|
//ArrayList<Route> routes = (ArrayList<Route>) Arrays.asList(getRoutesToDistrict(campaign.getHotelDistrict()));
|
|
|
|
//ArrayList<Route> routes = (ArrayList<Route>) Arrays.asList(getRoutesToDistrict(campaign.getHotelDistrict()));
|
|
|
|
Route[] routes = getRoutesToDistrict(campaign.getHotelDistrict());
|
|
|
|
Route[] routes = getRoutesToDistrict(campaign.getHotelDistrict());
|
|
|
@ -999,6 +985,11 @@ public class MakkahCity {
|
|
|
|
return sortingRoute;
|
|
|
|
return sortingRoute;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Find shortest path without respect to traffic
|
|
|
|
|
|
|
|
* @param campaign
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
public static Route getShortestRoute(Campaign campaign, Mashier mashier) {
|
|
|
|
public static Route getShortestRoute(Campaign campaign, Mashier mashier) {
|
|
|
|
Route[] routes = getRoutesToDistrict(campaign.getHotelDistrict());
|
|
|
|
Route[] routes = getRoutesToDistrict(campaign.getHotelDistrict());
|
|
|
|
Route route = null;
|
|
|
|
Route route = null;
|
|
|
@ -1035,8 +1026,8 @@ public class MakkahCity {
|
|
|
|
if (currenttimeManager == firstDayTimeMan) status = " Status: Heading to Arafat";
|
|
|
|
if (currenttimeManager == firstDayTimeMan) status = " Status: Heading to Arafat";
|
|
|
|
else status = " Status: Heading to hotels";
|
|
|
|
else status = " Status: Heading to hotels";
|
|
|
|
String headerFormat = "******Streets report*****\n" +
|
|
|
|
String headerFormat = "******Streets report*****\n" +
|
|
|
|
"Time: %s%s\n" +
|
|
|
|
"Time: %s%s\n" +
|
|
|
|
" Street name |Street Load| Total | Buses | Local Vehicles | Avg. Time |\n";
|
|
|
|
" Street name |Street Load| Total | Buses | Local Vehicles | Avg. Time |\n";
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder report = new StringBuilder();
|
|
|
|
StringBuilder report = new StringBuilder();
|
|
|
|
report.append(String.format(headerFormat, currenttimeManager.getCurrentTime(), status));
|
|
|
|
report.append(String.format(headerFormat, currenttimeManager.getCurrentTime(), status));
|
|
|
@ -1082,7 +1073,7 @@ public class MakkahCity {
|
|
|
|
if (Vehicle.getMaxArrived() != null && Vehicle.getMinArrived() != null) {
|
|
|
|
if (Vehicle.getMaxArrived() != null && Vehicle.getMinArrived() != null) {
|
|
|
|
report.append(String.format(" Maximum trip %s,", Vehicle.getMaxArrived().timeToString()));
|
|
|
|
report.append(String.format(" Maximum trip %s,", Vehicle.getMaxArrived().timeToString()));
|
|
|
|
report.append(String.format(" Minimum trip %s", Vehicle.getMinArrived().timeToString()));
|
|
|
|
report.append(String.format(" Minimum trip %s", Vehicle.getMinArrived().timeToString()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return report.toString();
|
|
|
|
return report.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1100,7 +1091,7 @@ public class MakkahCity {
|
|
|
|
for (Campaign campaign : listOfCampaigns){
|
|
|
|
for (Campaign campaign : listOfCampaigns){
|
|
|
|
for (Vehicle bus : campaign.getVehicles()){
|
|
|
|
for (Vehicle bus : campaign.getVehicles()){
|
|
|
|
if (bus.isArrivedToDest() && bus.getTimeOfArrival().before(now.getTime())
|
|
|
|
if (bus.isArrivedToDest() && bus.getTimeOfArrival().before(now.getTime())
|
|
|
|
&& bus.getTimeOfArrival().after(from.getTime())) {
|
|
|
|
&& bus.getTimeOfArrival().after(from.getTime())) {
|
|
|
|
long minutes = (bus.getTimeOfArrival().getTime() - bus.getTimeStartedMoving().getTime())/60000;
|
|
|
|
long minutes = (bus.getTimeOfArrival().getTime() - bus.getTimeStartedMoving().getTime())/60000;
|
|
|
|
sum+= minutes;
|
|
|
|
sum+= minutes;
|
|
|
|
counter++;
|
|
|
|
counter++;
|
|
|
@ -1146,7 +1137,7 @@ public class MakkahCity {
|
|
|
|
for (Campaign campaign : listOfCampaigns) {
|
|
|
|
for (Campaign campaign : listOfCampaigns) {
|
|
|
|
for (Vehicle vehicle : campaign.getVehicles()){
|
|
|
|
for (Vehicle vehicle : campaign.getVehicles()){
|
|
|
|
if (vehicle instanceof Bus &&
|
|
|
|
if (vehicle instanceof Bus &&
|
|
|
|
vehicle.isArrivedToDest()) num++;
|
|
|
|
vehicle.isArrivedToDest()) num++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return num;
|
|
|
|
return num;
|
|
|
@ -1160,7 +1151,7 @@ public class MakkahCity {
|
|
|
|
for (Campaign campaign : listOfCampaigns){
|
|
|
|
for (Campaign campaign : listOfCampaigns){
|
|
|
|
for (Vehicle bus : campaign.getVehicles()){
|
|
|
|
for (Vehicle bus : campaign.getVehicles()){
|
|
|
|
if (bus.isArrivedToDest() && bus.getTimeOfArrival().before(now.getTime())
|
|
|
|
if (bus.isArrivedToDest() && bus.getTimeOfArrival().before(now.getTime())
|
|
|
|
&& bus.getTimeOfArrival().after(from.getTime())) {
|
|
|
|
&& bus.getTimeOfArrival().after(from.getTime())) {
|
|
|
|
num++;
|
|
|
|
num++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1237,7 +1228,7 @@ public class MakkahCity {
|
|
|
|
if (!result) System.out.println("Could not save state "+currenttimeManager.getCurrentTime().getTime());
|
|
|
|
if (!result) System.out.println("Could not save state "+currenttimeManager.getCurrentTime().getTime());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static void updateStreetFrame() {
|
|
|
|
private static void updateStreetFrame() {
|
|
|
|
Object[][] streetData = new Object[stdStreet.length][6];
|
|
|
|
Object[][] streetData = new Object[stdStreet.length][6];
|
|
|
|
for (int i = 0; i < stdStreet.length; i++) {
|
|
|
|
for (int i = 0; i < stdStreet.length; i++) {
|
|
|
|
streetData[i][0] = stdStreet[i].getName().name();
|
|
|
|
streetData[i][0] = stdStreet[i].getName().name();
|
|
|
@ -1271,28 +1262,28 @@ public class MakkahCity {
|
|
|
|
if (lblArrivedToArafatTime.getText().equalsIgnoreCase("N/A"))
|
|
|
|
if (lblArrivedToArafatTime.getText().equalsIgnoreCase("N/A"))
|
|
|
|
if (allArrivedToArafatTime != null) {
|
|
|
|
if (allArrivedToArafatTime != null) {
|
|
|
|
lblArrivedToArafatTime.setText(allArrivedToArafatTime.toString());
|
|
|
|
lblArrivedToArafatTime.setText(allArrivedToArafatTime.toString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (lblArrivedToHotelsTime.getText().equalsIgnoreCase("N/A"))
|
|
|
|
if (lblArrivedToHotelsTime.getText().equalsIgnoreCase("N/A"))
|
|
|
|
if (allArrivedToHotelsTime != null) {
|
|
|
|
if (allArrivedToHotelsTime != null) {
|
|
|
|
lblArrivedToHotelsTime.setText(allArrivedToHotelsTime.toString());
|
|
|
|
lblArrivedToHotelsTime.setText(allArrivedToHotelsTime.toString());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String status = "";
|
|
|
|
|
|
|
|
if (currenttimeManager == firstDayTimeMan) {
|
|
|
|
|
|
|
|
status = "Heading to Arafat";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else{
|
|
|
|
|
|
|
|
status = "Heading to Hotels";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
lblDestination.setText(status);
|
|
|
|
|
|
|
|
|
|
|
|
String status = "";
|
|
|
|
int numberOfBusses = 0;
|
|
|
|
if (currenttimeManager == firstDayTimeMan) {
|
|
|
|
for (Campaign campaign : listOfCampaigns) {
|
|
|
|
status = "Heading to Arafat";
|
|
|
|
numberOfBusses += campaign.getNumberOfBusses();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
String bus = String.format("%d", numberOfBusses);
|
|
|
|
status = "Heading to Hotels";
|
|
|
|
lblNumOfBuses.setText(bus);
|
|
|
|
}
|
|
|
|
|
|
|
|
lblDestination.setText(status);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int numberOfBusses = 0;
|
|
|
|
|
|
|
|
for (Campaign campaign : listOfCampaigns) {
|
|
|
|
|
|
|
|
numberOfBusses += campaign.getNumberOfBusses();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
String bus = String.format("%d", numberOfBusses);
|
|
|
|
|
|
|
|
lblNumOfBuses.setText(bus);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String numOfdoneBuses = String.format("%d",getNumberOfArrivedBusses());
|
|
|
|
String numOfdoneBuses = String.format("%d",getNumberOfArrivedBusses());
|
|
|
|
lblNumOfDonebuses.setText(numOfdoneBuses);
|
|
|
|
lblNumOfDonebuses.setText(numOfdoneBuses);
|
|
|
@ -1308,44 +1299,44 @@ public class MakkahCity {
|
|
|
|
lblAverageTripForLastHourValue.setText(avgTimeOfTrip());
|
|
|
|
lblAverageTripForLastHourValue.setText(avgTimeOfTrip());
|
|
|
|
lblAverageTimeForTheTrip.setText(getAvgTripForAllDis());
|
|
|
|
lblAverageTimeForTheTrip.setText(getAvgTripForAllDis());
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static String getAvgTripForAllDis() {
|
|
|
|
public static String getAvgTripForAllDis() {
|
|
|
|
int sum = 0;
|
|
|
|
int sum = 0;
|
|
|
|
int counter = 1;
|
|
|
|
int counter = 1;
|
|
|
|
for (Campaign campaign : listOfCampaigns) {
|
|
|
|
for (Campaign campaign : listOfCampaigns) {
|
|
|
|
for (Vehicle vehicle : campaign.getVehicles()) {
|
|
|
|
for (Vehicle vehicle : campaign.getVehicles()) {
|
|
|
|
if (vehicle.isArrivedToDest()) {
|
|
|
|
if (vehicle.isArrivedToDest()) {
|
|
|
|
long minutes = (vehicle.getTimeOfArrival().getTime() - vehicle.getTimeStartedMoving().getTime())/60000;
|
|
|
|
long minutes = (vehicle.getTimeOfArrival().getTime() - vehicle.getTimeStartedMoving().getTime())/60000;
|
|
|
|
sum+= minutes;
|
|
|
|
sum+= minutes;
|
|
|
|
counter++;
|
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}//Make the following a method since it is the same other method
|
|
|
|
|
|
|
|
sum = sum /counter;
|
|
|
|
|
|
|
|
int hours = sum / 60;
|
|
|
|
|
|
|
|
int minutes = sum % 60;
|
|
|
|
|
|
|
|
if (hours == 0 && minutes == 0) return "-:--";
|
|
|
|
|
|
|
|
return String.format("%2d:%02d", hours,minutes);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static String getDistTimeForLbl() {
|
|
|
|
|
|
|
|
int numberOfBusses = 0;
|
|
|
|
|
|
|
|
int numberOfArrivedBuses = getNumberOfArrivedBusses();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (Campaign campaign : listOfCampaigns) {
|
|
|
|
|
|
|
|
numberOfBusses += campaign.getNumberOfBusses();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}//Make the following a method since it is the same other method
|
|
|
|
|
|
|
|
sum = sum /counter;
|
|
|
|
|
|
|
|
int hours = sum / 60;
|
|
|
|
|
|
|
|
int minutes = sum % 60;
|
|
|
|
|
|
|
|
if (hours == 0 && minutes == 0) return "-:--";
|
|
|
|
|
|
|
|
return String.format("%2d:%02d", hours,minutes);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
boolean Done = isAllArrived();
|
|
|
|
private static String getDistTimeForLbl() {
|
|
|
|
if (Done && allArrivedToArafatTime != null) {
|
|
|
|
int numberOfBusses = 0;
|
|
|
|
return String.format("%s", allArrivedToArafatTime);
|
|
|
|
int numberOfArrivedBuses = getNumberOfArrivedBusses();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Done && allArrivedToHotelsTime != null) {
|
|
|
|
for (Campaign campaign : listOfCampaigns) {
|
|
|
|
return String.format("%s",allArrivedToHotelsTime);
|
|
|
|
numberOfBusses += campaign.getNumberOfBusses();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "N/A";
|
|
|
|
|
|
|
|
}
|
|
|
|
boolean Done = isAllArrived();
|
|
|
|
|
|
|
|
if (Done && allArrivedToArafatTime != null) {
|
|
|
|
|
|
|
|
return String.format("%s", allArrivedToArafatTime);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Done && allArrivedToHotelsTime != null) {
|
|
|
|
|
|
|
|
return String.format("%s",allArrivedToHotelsTime);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "N/A";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|