Meeting work
Signed-off-by: HeshamTB <hishaminv@gmail.com> Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
83fddd5724
commit
92661695b1
@ -2,9 +2,9 @@ import java.util.*;
|
|||||||
|
|
||||||
public class MakkahCity {
|
public class MakkahCity {
|
||||||
|
|
||||||
private static final ArrayList<Campaign> allCampgains = new ArrayList<>();
|
private static final ArrayList<Campaign> listOfCampaigns = new ArrayList<>();
|
||||||
|
|
||||||
private static final ArrayList<Vehicle> vehiclesList = new ArrayList<>();
|
private static final ArrayList<Vehicle> listOfVehicles = new ArrayList<>();
|
||||||
private static final Route[] stdRoutes = new Route[9];
|
private static final Route[] stdRoutes = new Route[9];
|
||||||
private static final Street[] stdStreet = new Street[8];
|
private static final Street[] stdStreet = new Street[8];
|
||||||
|
|
||||||
@ -23,16 +23,47 @@ public class MakkahCity {
|
|||||||
//Make Routes
|
//Make Routes
|
||||||
makeRoutes();
|
makeRoutes();
|
||||||
|
|
||||||
|
//Set Routes for Campaigns
|
||||||
|
setRoutesForCampaigns();
|
||||||
|
|
||||||
while(!PDate.isEnded()) {
|
while(!PDate.isEnded()) {
|
||||||
PDate.step(Calendar.MINUTE, 1);
|
PDate.step(Calendar.MINUTE, 1);
|
||||||
|
System.out.println(PDate.getCurrentTime());
|
||||||
//TODO: add civil cars in loop itirations.
|
//TODO: add civil cars in loop itirations.
|
||||||
|
|
||||||
//TODO: Move busses and vehicles.
|
//TODO: Move busses and vehicles.
|
||||||
|
|
||||||
//TODO: Update streets.
|
//TODO: Update streets.
|
||||||
|
|
||||||
//TODO: Streets move forward.
|
//TODO: Streets move forward.
|
||||||
|
|
||||||
//TODO: update vehicles on street.
|
//TODO: update vehicles on street.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static int getRandom(int min, int max) {
|
private static int getRandom(int min, int max) {
|
||||||
return (int)(Math.random() * (max - min) + min);
|
return (int)(Math.random() * (max - min) + min);
|
||||||
}
|
}
|
||||||
@ -40,30 +71,72 @@ public class MakkahCity {
|
|||||||
private static void generateCamps(District area, int count) {
|
private static void generateCamps(District area, int count) {
|
||||||
for (int i = 0; i < count; i++){
|
for (int i = 0; i < count; i++){
|
||||||
Campaign camp = new Campaign(area, getRandom(10, 15));
|
Campaign camp = new Campaign(area, getRandom(10, 15));
|
||||||
allCampgains.add(camp);
|
listOfCampaigns.add(camp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void makeStreets(){
|
private static void makeStreets(){
|
||||||
stdStreet[StreetNames.KA_STREET] = new Street(22700,3);
|
stdStreet[StreetNames.KA_STREET] = new Street(22700,3);
|
||||||
stdStreet[StreetNames.FOURTH_HISHWAY] = new Street(24600,4);
|
stdStreet[StreetNames.FOURTH_HIGHWAY] = new Street(24600,4);
|
||||||
stdStreet[StreetNames.THIRD_HIGHWAY] = new Street(22000,3);
|
stdStreet[StreetNames.KUDAY] = new Street(22000,3);
|
||||||
stdStreet[StreetNames.STREET1] = new Street(4000,2);
|
stdStreet[StreetNames.STREET1] = new Street(4000,2);
|
||||||
stdStreet[StreetNames.STREET2] = new Street(7000,2);
|
stdStreet[StreetNames.STREET2] = new Street(7000,2);
|
||||||
stdStreet[StreetNames.STREET3] = new Street(400,2);
|
stdStreet[StreetNames.STREET3] = new Street(400,2);
|
||||||
stdStreet[StreetNames.STREET4] = new Street(8200,2);
|
stdStreet[StreetNames.STREET4] = new Street(8200,2);
|
||||||
stdStreet[StreetNames.STREET5] = new Street(100,2); //TODO: Change numbers
|
stdStreet[StreetNames.IBRAHIM_ALKHALIL] = new Street(100,2); //TODO: Change numbers
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void makeRoutes() {
|
private static void makeRoutes() {
|
||||||
// stdRoutes [RouteName.mashierToAlMansoor1] = new Route({stdStreet[]}, hotelArea, mashier)
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void fillBusesToList() {
|
private static void fillBusesToList() {
|
||||||
for (Campaign camp : allCampgains) {
|
for (Campaign camp : listOfCampaigns) {
|
||||||
vehiclesList.addAll(camp.getVehicles());
|
listOfVehicles.addAll(camp.getVehicles());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,11 @@ public class Street {
|
|||||||
|
|
||||||
|
|
||||||
public Street(double length, int numberOfLanes) {
|
public Street(double length, int numberOfLanes) {
|
||||||
|
vehicles = new ArrayList<>();
|
||||||
setLength(length);
|
setLength(length);
|
||||||
setNumberOfLanes(numberOfLanes);
|
setNumberOfLanes(numberOfLanes);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: should be removed. list can be over the capacity Unless we check with street cap.
|
|
||||||
public Street(double length, int numberOfLanes, ArrayList<Vehicle> vehicles) {
|
|
||||||
this(length, numberOfLanes);
|
|
||||||
this.vehicles = vehicles;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setLength(double length) {
|
private void setLength(double length) {
|
||||||
if (length >= 0) this.length = length;
|
if (length >= 0) this.length = length;
|
||||||
else throw new IllegalArgumentException("Can not make a negative length street");
|
else throw new IllegalArgumentException("Can not make a negative length street");
|
||||||
@ -63,10 +58,10 @@ public class Street {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean canTakeVehicles( Vehicle vehicle ) {
|
public boolean canTakeVehicles( Vehicle vehicle ) {
|
||||||
if ( vehicle.getVehicleSize() > capcity() )
|
if ( vehicle.getVehicleSize() + 0.5 < capcity() )
|
||||||
return false;
|
|
||||||
else
|
|
||||||
return true;
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addVehicle(Vehicle vehicle) {
|
public void addVehicle(Vehicle vehicle) {
|
||||||
|
@ -4,12 +4,12 @@
|
|||||||
public class StreetNames {
|
public class StreetNames {
|
||||||
|
|
||||||
public static final int KA_STREET = 0;
|
public static final int KA_STREET = 0;
|
||||||
public static final int THIRD_HIGHWAY = 1;
|
public static final int KUDAY = 1;
|
||||||
public static final int FOURTH_HISHWAY = 2;
|
public static final int FOURTH_HIGHWAY = 2;
|
||||||
public static final int STREET1 = 3;
|
public static final int STREET1 = 3;
|
||||||
public static final int STREET2 = 4;
|
public static final int STREET2 = 4;
|
||||||
public static final int STREET3 = 5;
|
public static final int STREET3 = 5;
|
||||||
public static final int STREET4 = 6;
|
public static final int STREET4 = 6;
|
||||||
public static final int STREET5 = 7;
|
public static final int IBRAHIM_ALKHALIL = 7;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,8 @@ public abstract class Vehicle {
|
|||||||
|
|
||||||
private double vehicleSize;
|
private double vehicleSize;
|
||||||
private Route route;
|
private Route route;
|
||||||
|
private Street currentStreet;
|
||||||
|
private double currentLocation;
|
||||||
|
|
||||||
public Vehicle(double vehicleSize){
|
public Vehicle(double vehicleSize){
|
||||||
setVehicleSize(vehicleSize);
|
setVehicleSize(vehicleSize);
|
||||||
@ -22,4 +24,19 @@ public abstract class Vehicle {
|
|||||||
if (vehicleSize <= 0) throw new IllegalArgumentException("Vehicle can not be negative in length!");
|
if (vehicleSize <= 0) throw new IllegalArgumentException("Vehicle can not be negative in length!");
|
||||||
else this.vehicleSize = vehicleSize;
|
else this.vehicleSize = vehicleSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Street getCurrentStreet() {
|
||||||
|
return currentStreet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getCurrentLocation() {
|
||||||
|
return currentLocation;
|
||||||
|
}
|
||||||
|
|
||||||
|
//TODO: Manage movement and setStreet and location ons street.
|
||||||
|
|
||||||
|
public void moveForward(double distance) {
|
||||||
|
//TODO: Check if at end of street move to next street in Route.
|
||||||
|
this.currentLocation += distance;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user