Design Patterns, Behavioural Design, Java, Software Development.
YellowLightState implements TrafficLightState { public void handleState(TrafficLight context) { System.out.println("Yellow Light: Prepare to Stop"); // Transition to the next state context.setState(new RedLightState()); } } // Context class TrafficLight { private TrafficLightState currentState;