Created
March 14, 2022 13:55
-
-
Save heemskerkerik/e4bc9b86e096b1f0645041dedd069d5c to your computer and use it in GitHub Desktop.
This file contains hidden or 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
static State ChangeState(State current, Transition transition, bool hasKey) | |
{ | |
if (current == Opened && transition == Close) | |
return Closed; | |
else if (current == Closed && transition == Open) | |
return Open; | |
else if (current == Closed && transition == Lock && hasKey) | |
return Locked; | |
else if (current == Locked && transition == Unlock && hasKey) | |
return Closed; | |
else | |
throw new InvalidOperationException($"Invalid transition"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment