added some more print stuf
This commit is contained in:
1 parent
eaa8942116
commit
da60d4f352
3 files changed
+8
-2
No files matched your search
@@ -16,7 +16,7 @@ public class BridgeSimulator {
|
||||
|
||||
Random rand = new Random();
|
||||
for (int i = 0; i < emergencies; i++)
|
||||
emergencyTimes.add(rand.nextInt(simulationTime));
|
||||
emergencyTimes.add(rand.nextInt(simulationTime - 1));
|
||||
|
||||
int currentSimTime = 0;
|
||||
long lastTime = System.currentTimeMillis();
|
||||
@@ -57,7 +57,9 @@ public class BridgeSimulator {
|
||||
|
||||
int totalVehicles = trafficController.carCounter + trafficController.emergencyCounter + trafficController.truckCounter;
|
||||
|
||||
System.out.println("\nSimulation concludes after " + simulationTime + " seconds.");
|
||||
System.out.println("Total Vehicles: " + totalVehicles + ", Cars: " + trafficController.carCounter + ", Trucks: " + trafficController.truckCounter + ", Emergency Vehicles: " + trafficController.emergencyCounter + ", Vehicles Crossed: " + trafficController.crossings);
|
||||
System.out.println(trafficController.left + " turned away due to excessive wait times.");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ public class TrafficController {
|
||||
public int carCounter = 0;
|
||||
public int emergencyCounter = 0;
|
||||
public int crossings = 0;
|
||||
public int left = 0;
|
||||
|
||||
boolean northLast = true;
|
||||
|
||||
|
||||
+4
-1
@@ -33,8 +33,11 @@ public abstract class Vehicle implements Runnable {
|
||||
|
||||
if (queue.tryAcquire())
|
||||
trafficController.queueVehicle(this);
|
||||
else
|
||||
else {
|
||||
System.out.println(this.getType() + " " + id + " saw too many cars and left.");
|
||||
trafficController.left++;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// try {
|
||||
|
||||
Reference in new issue
Block a user