Skip to content

Instantly share code, notes, and snippets.

@hackjutsu
Created May 23, 2019 04:35
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/deab2d9ab54a52c1b790fcb7227c992d to your computer and use it in GitHub Desktop.
Save hackjutsu/deab2d9ab54a52c1b790fcb7227c992d to your computer and use it in GitHub Desktop.
[medium snippets] #medium #designPattern #StatePattern
public class MP3PlayerContext {
private State state;
public MP3PlayerContext() {
this.state = new StandbyState();
}
public void press() {
state.pressPlay(this);
}
public void setState(State state) {
this.state = state;
}
public void getState() {
System.out.println(state.getState());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment