Package Behavioral.State
Class Context
java.lang.Object
Behavioral.State.Context
Context class maintaining a reference to a state instance.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the name of the current state.voidrequest()Requests the current state's handle behavior.voidSets the state of the context.
-
Constructor Details
-
Context
Constructs a Context with an initial state.- Parameters:
initialState- The initial state of the context.
-
-
Method Details
-
request
public void request()Requests the current state's handle behavior. -
setState
Sets the state of the context.- Parameters:
state- The new state to transition to.
-
getStateName
Gets the name of the current state.- Returns:
- The name of the current state.
-