Question: StackADT Code: public interface StackADT { public void push(T element); public T pop(); public T peek(); public boolean isEmpty(); public int size(); } LinearNode Code:




StackADT
public interface StackADT
LinearNode Code:
public class LinearNode
private LinearNode
public LinearNode() { this(null); } public LinearNode(T elem) { next = null; element = elem; } public LinearNode
Everything should be here, please follow the UML as well as code in Java. Thanks in advance!
Create a class called "DropOutStack". See Figure 1 for UML. What is a drop out stack? Same thing as a regular stack, except with a maximum capacity. Whenever a new element is added when the stack is full, the bottom-most element must be removed from the collection (see Figure 2). The new element is then inserted and the size and max capacity shouldn't change. Be sure to keep the following stipulations in mind: You must rely on links for its underlying data structure. Tip: Reuse and modify class 'LinkedStack' since its generics and attributes are already established and are still important to have. The code within interface 'StackADT' and class 'LinearNode' should be the same as they originally were. Note: There's no 'count' attribute, however if students want to create / maintain one, that's fine. A11 [four] constructors serve similar purposes and should work like so: The starting value for attribute 'maxSize' will depend on what value the constructor's integer parameter is, otherwise if said parameter doesn't exist it should be 10 (by default). Important: You MUST invoke the class' own mutator method to handle said assignment operation. The constructors which have the 'T' parameter must set said element as the starting 'top' node of the collection (otherwise it should remain null). Tip: Focus on implementing the 4th constructor (the one with two parameters) and have the other constructors invoke it, using the 'this' keyword, with appropriate arguments. Don't forget that the "pop" and "peek" method MUST throw a (runtime] exception if the stack is empty. Tip: For method "push", check the capacity limit AFTER inserting the element into the collection. Hint: If the last node needs to be decoupled from the collection, then this will require us to find and modify the 'next' reference of the second-to-last node in the sequence. Here's how the "pop Stack" function should work: It should throw a [runtime] exception if it's parameter 'capacity' exceeds the stack's (current) size, otherwise ... It'll return an array consisting of
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
