A link is given that connects to a website called Bridges, which is an API storage of random digits and strings to enter into the stack. The code needs to be generic and import data from an external site.
Programming Project 4 - Custom Stack Implementation
Note: When you turn in an assignment to be graded in this class, you are making the claim that you neither gave nor received assistance on the work you turned in (except, of course, assistance from your instructor). Any assistance from other sources, including the internet, is an honor code violation.
In this project, you will implement a Stack.
1. You will write a CustomStack<E> class that implements the StackInterface<E> shown here:
package cmsc256;
public interface StackInterface<E> {
/** Adds a new entry to the top of this stack.
* @param newEntry An object to be added to the stack. */
public void push(E newEntry);
/** Removes and returns this stack's top entry.
* @return The object at the top of the stack.
* @throws EmptyStackException if the stack is empty before the operation. */
public E pop();
/** Retrieves this stack's top entry.
* @return The object at the top of the stack.
* @throws EmptyStackException if the stack is empty. */
public E peek();
/** Detects whether this stack is empty.
* @return True if the stack is empty. */
public boolean isEmpty();
/** Removes all entries from this stack. */
public void clear();
}
2. Represents a singly-linked node. More information and a sample program can be found here - http://bridgesuncc.github.io/tutorials/SinglyLinkedList.html
3. To view the contents of the stack, you will need a display() method within the CustomStack<E> class that will provide an output of the stack. The following code may be used:
public void display() {
if (isEmpty()) {
System.out.println("The stack is empty");
} else {
SLelement<T> current = topNode;
StringBuffer output = new StringBuffer();
while (current.getNext() != null) {
current = current.getNext();
if (current.getNext() == null) {
// Do something
} else {
output.append("\n");
output.append(current.getValue() + "\n");
}
}
System.out.println(output.toString());
}
}