Files
java-design-patterns/command/src/main/java/com/iluwatar/App.java
2014-10-08 13:42:12 +01:00

26 lines
572 B
Java

package com.iluwatar;
/**
*
* In Command pattern actions are objects that can be executed and undone. The
* commands in this example are spells cast by the wizard on the goblin.
*
*/
public class App {
public static void main(String[] args) {
Wizard wizard = new Wizard();
Goblin goblin = new Goblin();
goblin.printStatus();
wizard.castSpell(new ShrinkSpell(), goblin);
goblin.printStatus();
wizard.castSpell(new InvisibilitySpell(), goblin);
goblin.printStatus();
wizard.undoLastSpell();
goblin.printStatus();
}
}