Question: Design and implement a special kind of stack (lets call it FL_Stack which stand for Fixed Length Stack). A FL_Stack behaves exactly like a regular
Design and implement a special kind of stack (lets call it FL_Stack which stand for Fixed Length Stack). A FL_Stack behaves exactly like a regular stack except that it abandons the first element which is pushed into the stack at first when the stack is full, and a new element is pushed into the stack. In other words, the stack does not expand and keeps the initial capacity. Implement the FL_Stack class with all stack methods using an array. Do not extend the ArrayStack class. Add the following method:
public T peekFirst(): returns a reference to the element at the bottom of this stack. The element is not removed from the stack.
@return element on bottom of stack
@throws EmptyCollectionException if stack is empty
Write a driver program to test ALL methods. Display the content of the stack to show whether the stack works according to the description above.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
