public final class CommandHistoryObj extends java.lang.Object implements CommandHistory
Modifier and Type | Field and Description |
---|---|
(package private) java.util.Stack<Command> |
redoStack |
(package private) java.util.Stack<Command> |
undoStack |
Constructor and Description |
---|
CommandHistoryObj() |
Modifier and Type | Method and Description |
---|---|
void |
add(Command cmd)
Add command
undoable and clear redoable . |
boolean |
redo()
Pop command from
redoable , redo it, then push it
onto undoable . |
(package private) Command |
topRedoCommand() |
(package private) Command |
topUndoCommand() |
boolean |
undo()
Pop command from
undoable , undo it, then push it
onto redoable . |
public CommandHistoryObj()
public void add(Command cmd)
CommandHistory
undoable
and clear redoable
.add
in interface CommandHistory
cmd
- the command to be run.public boolean undo()
CommandHistory
undoable
, undo it, then push it
onto redoable
.undo
in interface CommandHistory
public boolean redo()
CommandHistory
redoable
, redo it, then push it
onto undoable
.redo
in interface CommandHistory
Command topUndoCommand()
Command topRedoCommand()