/** * An IntStack is an object that holds a stack of ints. */ public class IntStack { private Node top = null; // The top Node in the stack /** * Test whether this stack has more elements. * @return true if this stack is not empty */ public boolean hasMore() { return (top != null); } /** * Pop the top int from this stack and return it. * This should be called only if the stack is * not empty. * @return the popped int */ public int pop() { Node n = top; top = n.getLink(); return n.getData(); } /** * Push an int on top of this stack. * @param data the String to add */ public void push(int data) { top = new Node(data,top); } }