Question: The interface ExtendedStack provides the usual stack methods, as well as the methods count, which returns the number of elements currently in the stack, and

The interface ExtendedStack provides the usual stack methods, as well as the methods count, which returns the number of elements currently in the stack, and the method reverse, which reverses the elements in the stack. The interface definition is provided below. public interface Extended Stack {boolean isEmpty(); void push (String element); String pop(); String peek(); int count(); void reverse();} Someone has partially implemented this interface in the class ExtendedStackImplementation. Specifically, methods isEmtpy, push and pop are already (correctly) implemented. ExtendedStackImplementation has only one constructor, with no parameter. This implementation can accommodate any number of elements. Without making any assumptions on how ExtendedStackImplementation stores the stack (in particular, you cannot assume that the implementation uses an array) and using only the methods of ExtendedStack that have already been implemented (isEmtpy, push and pop), provide an implementation of the method peek. The method peek returns the top element of the stack without removing it. More precisely, after a call to the method peek, the content of the stack must be the same as it was before the call. You don't need to handle the error situations, in particular, you can assume that peek will not be called if the stack is empty
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
