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

JAVA O UndoStack Favorite Language/Type: Java classes mplementing inheritance Related LinksStringStack.java Author:

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!