Design Patterns, Behavioural Design, Java, Software Development.
Output: Red Light: Stop } } Real-world Use Case: Traffic Light System A common real-world use case for the State pattern is a traffic light system. The behavior of a traffic light varies based on its current state (red, green, or yellow). By implementing the State pattern, we can encapsulate the