Question: / * * 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 TrafficLight(String 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!