2020-11-09 22:10:31 +01:00
|
|
|
import java.util.*;
|
2020-11-08 01:05:52 +01:00
|
|
|
|
|
|
|
public class MakkahCity {
|
|
|
|
|
2020-11-10 18:15:11 +01:00
|
|
|
private static final ArrayList<Campaign> listOfCampaigns = new ArrayList<>();
|
2020-11-09 22:10:31 +01:00
|
|
|
|
2020-11-10 18:15:11 +01:00
|
|
|
private static final ArrayList<Vehicle> listOfVehicles = new ArrayList<>();
|
2020-11-09 22:10:31 +01:00
|
|
|
private static final Route[] stdRoutes = new Route[9];
|
|
|
|
private static final Street[] stdStreet = new Street[8];
|
|
|
|
|
2020-11-11 10:04:50 +01:00
|
|
|
private static final PDate timeManager = new PDate(
|
|
|
|
new GregorianCalendar(2020, Calendar.JANUARY, 1, 8, 0, 0),
|
|
|
|
new GregorianCalendar(2020, Calendar.JANUARY, 2, 8, 0, 0)
|
|
|
|
);
|
|
|
|
|
2020-11-08 01:05:52 +01:00
|
|
|
public static void main(String[] args) {
|
|
|
|
|
2020-11-09 22:10:31 +01:00
|
|
|
//Gen Camp
|
2020-11-10 14:45:35 +01:00
|
|
|
generateCamps(District.ALAZIZIYA, getRandom(70, 100));
|
|
|
|
generateCamps(District.ALMANSOOR, getRandom(110, 160));
|
2020-11-09 22:10:31 +01:00
|
|
|
generateCamps(District.ALHIJRA, getRandom(80, 110));
|
2020-11-10 15:06:28 +01:00
|
|
|
|
2020-11-09 22:43:16 +01:00
|
|
|
fillBusesToList();
|
2020-11-10 15:06:28 +01:00
|
|
|
|
2020-11-09 22:10:31 +01:00
|
|
|
//Make Streets
|
|
|
|
makeStreets();
|
2020-11-10 18:15:11 +01:00
|
|
|
|
2020-11-09 22:10:31 +01:00
|
|
|
//Make Routes
|
|
|
|
makeRoutes();
|
|
|
|
|
2020-11-10 18:15:11 +01:00
|
|
|
//Set Routes for Campaigns
|
|
|
|
setRoutesForCampaigns();
|
|
|
|
|
2020-11-10 18:48:32 +01:00
|
|
|
//TODO: Set Schedule for Campaigns
|
|
|
|
|
2020-11-11 10:04:50 +01:00
|
|
|
while(!timeManager.isEnded()) {
|
|
|
|
timeManager.step(Calendar.MINUTE, 1);
|
|
|
|
System.out.println(timeManager.getCurrentTime());
|
2020-11-10 18:48:32 +01:00
|
|
|
//TODO: add civil cars in loop iterations. (noise)
|
2020-11-10 18:15:11 +01:00
|
|
|
|
2020-11-09 22:10:31 +01:00
|
|
|
//TODO: Move busses and vehicles.
|
2020-11-10 18:15:11 +01:00
|
|
|
|
2020-11-09 22:10:31 +01:00
|
|
|
//TODO: Update streets.
|
2020-11-10 18:15:11 +01:00
|
|
|
|
2020-11-09 22:10:31 +01:00
|
|
|
//TODO: Streets move forward.
|
2020-11-10 18:15:11 +01:00
|
|
|
|
2020-11-09 22:10:31 +01:00
|
|
|
//TODO: update vehicles on street.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-10 18:15:11 +01:00
|
|
|
private static void setRoutesForCampaigns() {
|
|
|
|
for (Campaign camp : listOfCampaigns){
|
|
|
|
if (camp.getHotelDistrict() == District.ALAZIZIYA) {
|
|
|
|
setUpCampaginRoute(camp, RouteName.mashierToAlAzizi1);
|
|
|
|
}
|
|
|
|
else if (camp.getHotelDistrict() == District.ALMANSOOR){
|
|
|
|
setUpCampaginRoute(camp, RouteName.mashierToAlMansoor2);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
setUpCampaginRoute(camp, RouteName.mashierToAlHijra1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void setUpCampaginRoute(Campaign camp, int routeName) {
|
|
|
|
Route route = stdRoutes[routeName];
|
|
|
|
camp.setDestToHousingRoute(route);
|
|
|
|
//For now set all busses to one route
|
|
|
|
for(Vehicle vehicle : camp.getVehicles()){
|
|
|
|
vehicle.setRoute(route);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-11-09 22:10:31 +01:00
|
|
|
private static int getRandom(int min, int max) {
|
|
|
|
return (int)(Math.random() * (max - min) + min);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void generateCamps(District area, int count) {
|
|
|
|
for (int i = 0; i < count; i++){
|
|
|
|
Campaign camp = new Campaign(area, getRandom(10, 15));
|
2020-11-10 18:15:11 +01:00
|
|
|
listOfCampaigns.add(camp);
|
2020-11-09 22:10:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void makeStreets(){
|
2020-11-10 14:45:35 +01:00
|
|
|
stdStreet[StreetNames.KA_STREET] = new Street(22700,3);
|
2020-11-10 18:15:11 +01:00
|
|
|
stdStreet[StreetNames.FOURTH_HIGHWAY] = new Street(24600,4);
|
|
|
|
stdStreet[StreetNames.KUDAY] = new Street(22000,3);
|
2020-11-10 14:45:35 +01:00
|
|
|
stdStreet[StreetNames.STREET1] = new Street(4000,2);
|
|
|
|
stdStreet[StreetNames.STREET2] = new Street(7000,2);
|
|
|
|
stdStreet[StreetNames.STREET3] = new Street(400,2);
|
|
|
|
stdStreet[StreetNames.STREET4] = new Street(8200,2);
|
2020-11-10 18:15:11 +01:00
|
|
|
stdStreet[StreetNames.IBRAHIM_ALKHALIL] = new Street(100,2); //TODO: Change numbers
|
2020-11-08 01:05:52 +01:00
|
|
|
}
|
|
|
|
|
2020-11-09 22:10:31 +01:00
|
|
|
private static void makeRoutes() {
|
2020-11-10 18:15:11 +01:00
|
|
|
|
|
|
|
stdRoutes[RouteName.mashierToAlHijra1] = new Route(
|
|
|
|
new Street[]{
|
|
|
|
stdStreet[StreetNames.STREET1],
|
|
|
|
stdStreet[StreetNames.STREET2],
|
|
|
|
stdStreet[StreetNames.KUDAY]},
|
|
|
|
District.ALHIJRA, Mashier.ARAFAT);
|
|
|
|
|
|
|
|
stdRoutes[RouteName.mashierToAlHijra2] = new Route(new Street[]{
|
|
|
|
stdStreet[StreetNames.STREET1],
|
|
|
|
stdStreet[StreetNames.FOURTH_HIGHWAY],
|
|
|
|
stdStreet[StreetNames.STREET4]
|
|
|
|
},District.ALAZIZIYA, Mashier.ARAFAT);
|
|
|
|
|
|
|
|
stdRoutes[RouteName.mashierToAlMansoor1] = new Route(
|
|
|
|
new Street[]{
|
|
|
|
stdStreet[StreetNames.STREET1],
|
|
|
|
stdStreet[StreetNames.STREET2],
|
|
|
|
stdStreet[StreetNames.KA_STREET],
|
|
|
|
stdStreet[StreetNames.STREET3]
|
|
|
|
},District.ALMANSOOR, Mashier.ARAFAT);
|
|
|
|
|
|
|
|
stdRoutes[RouteName.mashierToAlMansoor2] = new Route(
|
|
|
|
new Street[]{
|
|
|
|
stdStreet[StreetNames.STREET1],
|
|
|
|
stdStreet[StreetNames.STREET2],
|
|
|
|
stdStreet[StreetNames.KUDAY],
|
|
|
|
stdStreet[StreetNames.IBRAHIM_ALKHALIL]//TODO: is actually half of ibrahim khalil.
|
|
|
|
},District.ALMANSOOR, Mashier.ARAFAT);
|
|
|
|
|
|
|
|
//Optimal for Almansoor
|
|
|
|
stdRoutes[RouteName.mashierToAlMansoor3] = new Route(
|
|
|
|
new Street[]{
|
|
|
|
stdStreet[StreetNames.STREET1],
|
|
|
|
stdStreet[StreetNames.FOURTH_HIGHWAY],
|
|
|
|
stdStreet[StreetNames.IBRAHIM_ALKHALIL]
|
|
|
|
},District.ALMANSOOR, Mashier.ARAFAT);
|
|
|
|
|
|
|
|
stdRoutes[RouteName.mashierToAlAzizi1] = new Route(
|
|
|
|
new Street[]{
|
|
|
|
stdStreet[StreetNames.STREET1],
|
|
|
|
stdStreet[StreetNames.STREET2],
|
|
|
|
stdStreet[StreetNames.KA_STREET]
|
|
|
|
},District.ALAZIZIYA, Mashier.ARAFAT);
|
|
|
|
|
2020-11-09 22:10:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private static void fillBusesToList() {
|
2020-11-10 18:15:11 +01:00
|
|
|
for (Campaign camp : listOfCampaigns) {
|
|
|
|
listOfVehicles.addAll(camp.getVehicles());
|
2020-11-09 22:43:16 +01:00
|
|
|
}
|
2020-11-09 22:10:31 +01:00
|
|
|
}
|
2020-11-10 18:48:32 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates 'noise' cars to be used in streets
|
|
|
|
* @param numberOfCars
|
|
|
|
* @return Array of 70% Sedans and 30% SUVs
|
|
|
|
*/
|
|
|
|
private static CivilVehicle[] generateCivilVehicles(int numberOfCars) {
|
|
|
|
CivilVehicle[] cars = new CivilVehicle[numberOfCars];
|
|
|
|
int sedans = (int)(numberOfCars*0.7);
|
|
|
|
int SUVs = numberOfCars - sedans;
|
|
|
|
for (int i = 0; i < sedans; i++) {
|
|
|
|
cars[i] = new Sedan(getRandom(25,32)/10);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < SUVs; i++) {
|
|
|
|
cars[sedans+i] = new SUV(getRandom(35,45)/10);
|
|
|
|
}
|
|
|
|
return cars;
|
|
|
|
}
|
2020-11-11 10:04:50 +01:00
|
|
|
|
|
|
|
public static PDate getTimeManager() {
|
|
|
|
return timeManager;
|
|
|
|
}
|
2020-11-08 01:05:52 +01:00
|
|
|
}
|