Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
当一个对象内在状态改变时允许其改变行为,这个对象看起来像改变了其类。
The classes and objects participating in this pattern are:
- defines the interface of interest to clients
- maintains an instance of a ConcreteState subclass that defines the current state.
- defines an interface for encapsulating the behavior associated with a particular state of the Context.
- each subclass implements a behavior associated with a state of Context