From 0fb689a3a006bf15fa104ca1aff08933c66dc1bd Mon Sep 17 00:00:00 2001 From: HeshamTB Date: Tue, 10 Nov 2020 00:10:31 +0300 Subject: [PATCH] MakkahCity: Main simulation begins - Defined static lists and arrays holding All object references. - Generate campaigns with random number range based on Area. This is based on estimate of real values and density of the Districts in Makkah. - Main loop is made and limited by PDate.isEnded() which is static variable indicates the end of the timeline. The incrementor is PDate.step(key,value) Simulation begins... - H.B. Signed-off-by: HeshamTB --- src/MakkahCity.java | 57 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/src/MakkahCity.java b/src/MakkahCity.java index 8b382b7..5c461f8 100644 --- a/src/MakkahCity.java +++ b/src/MakkahCity.java @@ -1,9 +1,62 @@ +import java.util.*; public class MakkahCity { - public static void main(String[] args) { - + private static final ArrayList allCampgains = new ArrayList<>(); + private static final ArrayList vehiclesList = new ArrayList<>(); + private static final Route[] stdRoutes = new Route[9]; + private static final Street[] stdStreet = new Street[8]; + + public static void main(String[] args) { + + //Gen Camp + generateCamps(District.ALAZIZIYA, getRandom(100, 150)); + generateCamps(District.ALMANSOOR, getRandom(90, 120)); + generateCamps(District.ALHIJRA, getRandom(80, 110)); + //Make Streets + makeStreets(); + //Make Routes + makeRoutes(); + + while(!PDate.isEnded()) { + PDate.step(Calendar.MINUTE, 1); + //TODO: add civil cars in loop itirations. + //TODO: Move busses and vehicles. + //TODO: Update streets. + //TODO: Streets move forward. + //TODO: update vehicles on street. + } } + 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)); + allCampgains.add(camp); + } + } + + private static void makeStreets(){ + //TODO: find values + stdStreet[StreetNames.KA_STREET] = new Street(500,3); + stdStreet[StreetNames.FOURTH_HISHWAY] = new Street(500,4); + stdStreet[StreetNames.THIRD_HIGHWAY] = new Street(500,3); + stdStreet[StreetNames.STREET1] = new Street(500,2); + stdStreet[StreetNames.STREET2] = new Street(500,2); + stdStreet[StreetNames.STREET3] = new Street(500,2); + stdStreet[StreetNames.STREET4] = new Street(500,2); + stdStreet[StreetNames.STREET5] = new Street(500,2); + } + + private static void makeRoutes() { + //TODO: find using maps. + } + + private static void fillBusesToList() { + //TODO: add all buses from campaigns to vehiclesList + } }