mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 06:58:41 +00:00
28 lines
625 B
Java
28 lines
625 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();
|
|
}
|
|
}
|