Question: fill the java code in the answer to complete the method For the question below, assume the following implementation of LinkedStack: 2 1 public class

 fill the java code in the answer to complete the method

For the question below, assume the following implementation of LinkedStack: 2 1

public class LinkedStack implements StackInterface { private Node topNode; private int numberofEntries;

fill the java code in the answer to complete the method

public LinkedStack() { this.topNode = null; numberofEntries = 0; }// end default

For the question below, assume the following implementation of LinkedStack: 2 1 public class LinkedStack implements StackInterface { private Node topNode; private int numberofEntries; public LinkedStack() { this.topNode = null; numberofEntries = 0; }// end default constructor 8 9 10 11 12 @Override public void push(T newEntry) { topNode = new Node(newEntry, topNode); numberofEntries++; 13 14 15 16 17 18 19 20 21 Coverride public peek() { if (isEmpty()) { throw new EmptyStackexception(); } else { return (T)topNode.getData(); } } // end peek 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 @Override public T pop() { T top = peek(); topNode = topNode.getNext(); numberofEntries--; return top; @Override public boolean isEmpty() { return topNode == null; } 39 40 41 @Override public void clear() { topNode = null; } // end LinkedStack public class Node { private E data; // Entry in bag private Node next; // Link to next node public Node (E dataPortion) { this(dataPortion, null); } // end constructor public Node (E dataPortion, Node nextNode) { data = dataPortion; next = nextNode; } // end constructor public e getData() { if (data != null) { return data; } return null; public Node getNext() { return next; } public void setNext (Node newNext) { next = newNext; } } // end Node Below, you'll see the start of a method to find the bottom item in a stack. So if you had the following code: LinkedStack lstack = new LinkedStack(); Istack.push(5); Istack.push(10); 4 Istack.push(15); running Istack.getBaseOfStack() would return 5. Add in the code to finish this method. Your Answer: @suppressWarnings("unchecked") 2 public T getBaseOfStack() { Node currentNode; 3 4 5 6 7 return currentNode.getData()

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!