Created
September 6, 2016 14:11
-
-
Save donabrams/c451bca318c80cb55f10eeb0c95de478 to your computer and use it in GitHub Desktop.
Example Java State Machine
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 Post { | |
public enum PostStatus { | |
PENDING, PUBLISHED, UNPUBLISHED | |
} | |
private PostStatus status; | |
public void post() { | |
this.status = PostStatus.PUBLISHED; | |
} | |
public void unpublish() { | |
this.status = PostStatus.UNPUBLISHED; | |
} | |
public void getStatus() { | |
return this.status; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment