public class TrafficLight { public static final byte RED = 1; public static final byte YELLOW = 2; public static final byte GREEN = 3; public int state; // The current state of the traffic light public int timeRemaining; // Seconds remaining in this state public TrafficLight(byte iState) { state = iState; timeRemaining = 0; } public String toString() { switch(state) { case RED: return "RED traffic light"; case YELLOW: return "YELLOW traffic light"; case GREEN: return "GREEN traffic light"; default: return "OFF traffic light"; } } }