Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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