added some more print stuf

This commit is contained in:
JISAUAY committed 2024-10-09 09:57:37 -05:00
1 parent eaa8942116
commit da60d4f352
3 files changed
+8 -2

No files matched your search

+3 -1
View File
@@ -16,7 +16,7 @@ public class BridgeSimulator {
Random rand = new Random(); Random rand = new Random();
for (int i = 0; i < emergencies; i++) for (int i = 0; i < emergencies; i++)
emergencyTimes.add(rand.nextInt(simulationTime)); emergencyTimes.add(rand.nextInt(simulationTime - 1));
int currentSimTime = 0; int currentSimTime = 0;
long lastTime = System.currentTimeMillis(); long lastTime = System.currentTimeMillis();
@@ -57,7 +57,9 @@ public class BridgeSimulator {
int totalVehicles = trafficController.carCounter + trafficController.emergencyCounter + trafficController.truckCounter; 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("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.");
} }
+1
View File
@@ -8,6 +8,7 @@ public class TrafficController {
public int carCounter = 0; public int carCounter = 0;
public int emergencyCounter = 0; public int emergencyCounter = 0;
public int crossings = 0; public int crossings = 0;
public int left = 0;
boolean northLast = true; boolean northLast = true;
+4 -1
View File
@@ -33,8 +33,11 @@ public abstract class Vehicle implements Runnable {
if (queue.tryAcquire()) if (queue.tryAcquire())
trafficController.queueVehicle(this); trafficController.queueVehicle(this);
else else {
System.out.println(this.getType() + " " + id + " saw too many cars and left."); System.out.println(this.getType() + " " + id + " saw too many cars and left.");
trafficController.left++;
}
// //
// try { // try {