Class Context

java.lang.Object
Behavioral.State.Context

public class Context extends Object
Context class maintaining a reference to a state instance.
  • Constructor Details

    • Context

      public Context(State initialState)
      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

      public void setState(State state)
      Sets the state of the context.
      Parameters:
      state - The new state to transition to.
    • getStateName

      public String getStateName()
      Gets the name of the current state.
      Returns:
      The name of the current state.