Design Patterns, Behavioural Design, Java, Software Development.
public TrafficLight() { // Initial state currentState = new RedLightState(); } public void setState(TrafficLightState state) { currentState = state; } public void changeState() { currentState.handleState(this); } } // Client code public class StatePatternDemo { public static void main(String[]