Last active
May 6, 2020 18:06
-
-
Save DannyRusnok/8b1a44ee6a5b808404a16abb3050e5d6 to your computer and use it in GitHub Desktop.
State Pattern - Bark State
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BarkState : IDogState | |
{ | |
public void EnterState(DogContext context) | |
{ | |
context.StartBarking(); | |
/*etc these are examples what might a Dog class do*/ | |
} | |
public void Bark(DogContext context) { throw new NotSupportStateTransitionException(); } | |
public void Sleep(DogContext context) | |
{ | |
context.StopBarking(); | |
context.TransitionToState(new SleepState()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment