Question: JAVA O UndoStack Favorite Language/Type: Java classes mplementing inheritance Related LinksStringStack.java Author: Robert Baxter Assume there is a class StringStack that provides an implementation of
JAVA

O UndoStack Favorite Language/Type: Java classes mplementing inheritance Related LinksStringStack.java Author: Robert Baxter Assume there is a class StringStack that provides an implementation of a stack of String objects Method/Constructor Description public stringstack() public void push(String s) pushes s onto the top of the stack public string pop () public boolean isEmpty) true if stack is empty, false otherwise public int size( constructs an empty stringstack with given seed for random numbers removes and returns the top of the stack returns the number of elements in the stack Write a class UndoStack that extends the functionality of the StringStack class to allow an "undo" operation. Any push or pop can be undone by a call to undo. If several push and/or pop operations have been performed, it should be possible to perform several undos in a row, each reversing the most recent operation. If no push or pop operations have been performed, or if they have all been undone, there is nothing to undo. Provide a mechanism for checking whether or not there is something left to undo Method/Constructor Description public Undostack() public void undo() constructs an empty Undostack with given seed for random numbers undoes most recent push/pop that hasn't already been undone (throws IllegalstateException if nothing to undo) public boolean canUndo) returns true if there is something to undo, false otherwise You may use your own data structures, but you must rely on the existingclass to do basic stack operations
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
