001package myhw3.command;
002import java.util.Stack;
003
004public final class CommandHistoryObj implements CommandHistory {
005        Stack<Command> undoStack = new Stack<Command>();
006        Stack<Command> redoStack = new Stack<Command>();
007
008        public void add(Command cmd) {
009                // TODO
010        }
011
012        public boolean undo() {
013                boolean result = !undoStack.empty();
014                if (result) {
015                        // TODO
016                }
017                return result;
018        }
019
020        public boolean redo() {
021                boolean result = !redoStack.empty();
022                if (result) {
023                        // TODO
024                }
025                return result;
026        }
027
028        // For testing
029        Command topUndoCommand() {
030                if (undoStack.empty())
031                        return null;
032                else
033                        return undoStack.peek();
034        }
035        // For testing
036        Command topRedoCommand() {
037                if (redoStack.empty())
038                        return null;
039                else
040                        return redoStack.peek();
041        }
042}