Answered step by step
Verified Expert Solution
Question
1 Approved Answer
/ * * A simulated traffic light. * / public class TrafficLight { private int steps; / * * Constructs a green traffic light. *
A simulated traffic light.
public class TrafficLight
private int steps;
Constructs a green traffic light.
public TrafficLight
Your code goes here
Constructs a traffic light.
@param initialColor the initial color "green", "yellow", or "red"
public TrafficLightString initialColor
Your code goes here
Moves this traffic light to the next color.
public void next
steps;
Returns the current color of this traffic light.
@return the current color
public String getColor
Your code goes here
Counts how often this traffic light has been red.
@return the number of times this traffic light has been red
public int getReds
Your code goes here
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started