/** * Simple integer Stack implementation. * @author cs416 * @version 1 */ public class Stack { /* * Design details: * The internal array capacitiy if fixed at 10 integers * top represents the open top index of the Stack * This means that the "actual" value on the top of the stack is at * index top - 1 */ private final int capacity = 10; private int top = 0; private int[] a = new int[capacity]; /** * Returns true if Stack is empty otherwise false. * @return boolean */ public boolean isEmpty() { throw new UnsupportedOperationException("TO BE IMPLEMENTED"); } /** * Pushes the integer on top of the stack if there is space. * throws an IllegalStateException if push on to a full stack * @param x Value to add to the Stack. */ public void push(int x) { throw new UnsupportedOperationException("TO BE IMPLEMENTED"); } /** * Returns and removes the integer on top of the Stack. * throws an IllegalStateException if pop on an empty stack * @return int */ public int pop() { throw new UnsupportedOperationException("TO BE IMPLEMENTED"); } /** * Returns the integer on the top of the stack. * throws an IllegalStateException if peek on an empty stack * @return int */ public int peek() { throw new UnsupportedOperationException("TO BE IMPLEMENTED"); } /** * Returns the String representation of the Stack. * Examples: * If the Stack is empty, returns "[] <- top" * If the Stack contains 1, returns "[1] <- top" * If the Stack contains 1, 2, 3, return "[1, 2, 3] <- top" * @return String */ public String toString() { throw new UnsupportedOperationException("TO BE IMPLEMENTED"); } }