Design: State Pattern Implementation
Design and implement the state pattern for a single context object with multiple states. Out of scope are concurrency handling, persistence, and UI integration.
Functional Requirements
FR1: Design a system that allows an object to change its behavior when its internal state changes.
FR2: The system should encapsulate state-specific behavior in separate state objects.
FR3: Clients should interact with the context object without knowing the current state.
FR4: Support adding new states without modifying existing code.
FR5: Ensure that state transitions are handled cleanly and maintainably.
Non-Functional Requirements
NFR1: The system should be easy to extend with new states.
NFR2: State transitions should be explicit and controlled.
NFR3: The design should avoid large conditional statements for state behavior.
NFR4: The system should be maintainable and testable.
