Created
May 23, 2019 04:38
-
-
Save hackjutsu/ec8c5c72e057ef8c3550bd819303525a to your computer and use it in GitHub Desktop.
[medium snippets] #medium #designPattern #StatePattern
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 PlayingState implements State { | |
public void pressPlay(MP3PlayerContext context) { | |
context.setState(new StandbyState()); | |
} | |
@Override | |
public String getState() { | |
return "Playing..."; | |
} | |
} |
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 StandbyState implements State { | |
public void pressPlay(MP3PlayerContext context) { | |
context.setState(new PlayingState()); | |
} | |
@Override | |
public String getState() { | |
return "Stand By..."; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment