The State pattern allows an object to alter its behavior when its internal state changes. How is this typically implemented?
-
A
Using large switch statements in a single class
-
B
Delegating behavior to a State object that changes at runtime
-
C
Using reflection to swap method implementations
-
D
Inheriting from multiple state base classes