Merge pull request #15 from EngOsamah/master

shuffle
This commit is contained in:
HeshamTB 2020-12-06 22:31:56 +03:00 committed by GitHub
commit 50e348de8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,7 +1,6 @@
import java.util.*; import java.util.*;
public class MakkahCity { public class MakkahCity {
private static final ArrayList<Campaign> listOfCampaigns = new ArrayList<>(); private static final ArrayList<Campaign> listOfCampaigns = new ArrayList<>();
@ -38,6 +37,8 @@ public class MakkahCity {
generateCamps(District.ALMANSOOR, (int)getRandom(1600, 1800)); generateCamps(District.ALMANSOOR, (int)getRandom(1600, 1800));
generateCamps(District.ALHIJRA, (int)getRandom(1400, 1600)); generateCamps(District.ALHIJRA, (int)getRandom(1400, 1600));
Collections.shuffle(listOfCampaigns);
fillBusesToList(); fillBusesToList();
makeStreets(); makeStreets();
@ -56,6 +57,9 @@ public class MakkahCity {
} }
else System.out.print("."); else System.out.print(".");
//TODO: setRout rework
//TODO: find Best Rout method
clearDoneCivilVehicles(); clearDoneCivilVehicles();
addCivilVehicleNoise(); addCivilVehicleNoise();
for (Vehicle vehicle : listOfVehicles) { for (Vehicle vehicle : listOfVehicles) {
@ -85,10 +89,11 @@ public class MakkahCity {
if (isAllArrived()) allArrivedToArafatTime = (Date)currenttimeManager.getCurrentTime().clone(); if (isAllArrived()) allArrivedToArafatTime = (Date)currenttimeManager.getCurrentTime().clone();
firstDayTimeMan.step(Calendar.MINUTE, 1); firstDayTimeMan.step(Calendar.MINUTE, 1);
} }
//TODO make report
currenttimeManager = lastDayTimeMan; currenttimeManager = lastDayTimeMan;
System.out.println("\n***************FINSHIED ARAFAT DAY***************"); System.out.println("\n***************FINSHIED ARAFAT DAY***************");
setRoutesForCampaigns(Mashier.MINA); setRoutesForCampaigns(Mashier.MINA);
//Collections.shuffle(listOfVehicles);
for (Vehicle vehicle : listOfVehicles) { for (Vehicle vehicle : listOfVehicles) {
vehicle.setCurrentStreet(null); vehicle.setCurrentStreet(null);
} }
@ -576,7 +581,7 @@ public class MakkahCity {
//Redundant loops slow down execution. find better sol. //Redundant loops slow down execution. find better sol.
for (Campaign campaign : listOfCampaigns) { for (Campaign campaign : listOfCampaigns) {
numberOfBusses += campaign.getNumberOfBusses(); numberOfBusses += campaign.getNumberOfBusses();
} //TODO Add max min time. }
String fFormat = "All arrived to %s at: %s"; String fFormat = "All arrived to %s at: %s";
boolean arr = isAllArrived();//since it has looping. use once. boolean arr = isAllArrived();//since it has looping. use once.
if (arr && allArrivedToArafatTime != null) if (arr && allArrivedToArafatTime != null)
@ -628,7 +633,7 @@ public class MakkahCity {
private static int getPercentArrival(District district) { private static int getPercentArrival(District district) {
int sum = 0; int sum = 0;
for (Campaign campaign : campPerDistrict[district.ordinal()]) { for (Campaign campaign : campPerDistrict[district.ordinal()]) {
sum += campaign.getPercentArrived(); sum += campaign.getNumberOfArrivedBuses();
} }
return sum/campPerDistrict[district.ordinal()].size(); return sum/campPerDistrict[district.ordinal()].size();
} }
@ -702,7 +707,7 @@ public class MakkahCity {
report.append(String.format(" %-20s|", getShortestRoute(campPerDistrict[i].get(0), Mashier.ARAFAT).getFastestTimeOfTravel(new Bus()))); report.append(String.format(" %-20s|", getShortestRoute(campPerDistrict[i].get(0), Mashier.ARAFAT).getFastestTimeOfTravel(new Bus())));
report.append(String.format(" %-22s|", getShortestRoute(campPerDistrict[i].get(0), Mashier.MINA).getFastestTimeOfTravel(new Bus()))); report.append(String.format(" %-22s|", getShortestRoute(campPerDistrict[i].get(0), Mashier.MINA).getFastestTimeOfTravel(new Bus())));
//Calc values per dist here. //Calc values per dist here.
//TODO: add arrived buses colum
report.append("\n"); report.append("\n");
} }
return report.toString(); return report.toString();