Skip to content

Instantly share code, notes, and snippets.

@hackjutsu
Created May 23, 2019 04:38
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 hackjutsu/ec8c5c72e057ef8c3550bd819303525a to your computer and use it in GitHub Desktop.
Save hackjutsu/ec8c5c72e057ef8c3550bd819303525a to your computer and use it in GitHub Desktop.
[medium snippets] #medium #designPattern #StatePattern
public class PlayingState implements State {
public void pressPlay(MP3PlayerContext context) {
context.setState(new StandbyState());
}
@Override
public String getState() {
return "Playing...";
}
}
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