Skip to content

Instantly share code, notes, and snippets.

@DannyRusnok
Last active May 6, 2020 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DannyRusnok/54f464b5d62e70dfa735b9e77e048bec to your computer and use it in GitHub Desktop.
Save DannyRusnok/54f464b5d62e70dfa735b9e77e048bec to your computer and use it in GitHub Desktop.
State Pattern - SleepState
public class SleepState : IDogState
{
public void EnterState(DogContext context)
{
context.SlowMetabolism();
context.Vision = false;
/*etc.. there are examples what might a Dog class do*/
}
public void Bark(DogContext context) { throw new NotSupportStateTransitionException(); }
public void Sleep(DogContext context) { throw new NotSupportStateTransitionException(); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment