private void doSimulation() { // add statements gasStationObj = new GasStation(numGasPumps, carQLimitation, 1); // Initialize GasStation // Time driver simulation loop for (int currentTime = 0; currentTime < simulationTime; currentTime++) { // Step 1: any new car enters the gas station? getCarData(); // Step 1.1: setup car data if (anyNewArrival) { if (gasStationObj.isCarQTooLong()) { numGoAway++; System.out.println("Car leaves because the queue was too long."); } else { somecar = new Car(carIdCounter, serviceDuration, currentTime); totalArrival++; gasStationObj.insertCarQ(somecar); System.out.println("Car " + totalArrival + " has arrived!"); // Step 1.2: check car waiting queue too long? } } else { System.out.println("\tNo new car!"); } // Step 2: free busy pumps, add to free pumpQ if (!gasStationObj.emptyBusyGasPumpQ()) { if (currentTime >= gasStationObj.getFrontBusyGasPumpQ().getEndIntervalTime()) { if (gasStationObj.numFreeGasPumps() < numGasPumps) { GasPump btp = gasStationObj.removeBusyGasPumpQ(); Car tempcar = btp.switchBusyToFree(); gasStationObj.insertFreeGasPumpQ(btp); } } } // Step 3: get free pumps to serve waiting cars if (gasStationObj.numFreeGasPumps() != 0 && !gasStationObj.emptyCarQ()) { GasPump fp = gasStationObj.removeFreeGasPumpQ(); Car tempscar = gasStationObj.removeCarQ(); gasStationObj.insertBusyGasPumpQ(fp); fp.switchFreeToBusy(tempscar, currentTime); numServed++; } if (anyNewArrival) { carIdCounter++; } if (!gasStationObj.emptyCarQ()) { totalWaitingTime++; } } } // end simulation loop