public class Car {
private int waitTime;
public Car(int waitTime) {
this.waitTime = waitTime;
}
public int getWaitTime() {
return waitTime;
}
}
public class TrafficLight {
private String color;
public TrafficLight(String color) {
this.color = color;
}
public void switchLight() {
color = color.equals("red") ? "green" : "red";
}
public String getColor() {
return color;
}
}
public class Street {
private Car[] cars;
private TrafficLight trafficLight;
public Street(Car[] cars, TrafficLight trafficLight) {
this.cars = cars;
this.trafficLight = trafficLight;
}
// Your task is to implement this method
public double calculateAverageWaitTime() {
// Your code here
}
}
public double calculateAverageWaitTime() {
int totalWaitTime = 0;
for (Car car : cars) {
totalWaitTime += car.getWaitTime();
}
return (double) totalWaitTime / cars.length;
}