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-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-09 22:10:31 +01:00
|
|
|
while(!PDate.isEnded()) {
|
|
|
|
PDate.step(Calendar.MINUTE, 1);
|
2020-11-10 18:15:11 +01:00
|
|
|
System.out.println(PDate.getCurrentTime());
|
2020-11-09 22:10:31 +01:00
|
|
|
//TODO: add civil cars in loop itirations.
|
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-08 01:05:52 +01:00
|
|
|
}
|