Created
May 20, 2019 05:16
-
-
Save hackjutsu/8367729101d9d07f31d676b18767dde0 to your computer and use it in GitHub Desktop.
[medium snippets] #medium #designPattern #CommandPattern
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 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