Skip to content

Instantly share code, notes, and snippets.

@hackjutsu
Created May 20, 2019 05:16
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/8367729101d9d07f31d676b18767dde0 to your computer and use it in GitHub Desktop.
Save hackjutsu/8367729101d9d07f31d676b18767dde0 to your computer and use it in GitHub Desktop.
[medium snippets] #medium #designPattern #CommandPattern
public class Client {
static public void main(String[] args) {
CommandA commandA = new CommandA(new ReceiverA());
CommandB commandB = new CommandB(new ReceiverB());
Invoker invoker = new Invoker();
invoker.setCommand(0, commandA);
invoker.setCommand(1, commandB);
invoker.onButtonWasPushed(0);
invoker.onButtonWasPushed(1);
invoker.undoButtonWasPushed();
invoker.onButtonWasPushed(1);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment