Package at.jku.ssw.fp.sect04_4.cmd_fp
Class CmdHandler
- java.lang.Object
-
- at.jku.ssw.fp.sect04_4.cmd_fp.CmdHandler
-
public class CmdHandler extends Object
Handler for commands. Allows undo of commands.- Author:
- Herbert Prähofer
-
-
Field Summary
Fields Modifier and Type Field Description private static CmdHandler
instance
Singleton command handlerprivate Deque<Command>
undoStack
Undo stack
-
Constructor Summary
Constructors Modifier Constructor Description private
CmdHandler()
Private constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doCmd(Command cmd)
Executes the command and stores it in the undo stack.static CmdHandler
getInstance()
Gets the singleton command handler.void
undoCmd()
Undoes the last command from the undo stack.
-
-
-
Field Detail
-
instance
private static CmdHandler instance
Singleton command handler
-
-
Method Detail
-
getInstance
public static CmdHandler getInstance()
Gets the singleton command handler.- Returns:
- the singleton command handler
-
doCmd
public void doCmd(Command cmd)
Executes the command and stores it in the undo stack.- Parameters:
cmd
- the command to execute
-
undoCmd
public void undoCmd()
Undoes the last command from the undo stack.
-
-