// Stack.java // AP interface for stacks public interface Stack { /** * postcondition: returns true if stack is empty; * otherwise, returns false */ boolean isEmpty(); /** * precondition: stack is [e1, e2, ..., en] with n >= 0 * postcondition: stack is [e1, e2, ..., en, x] */ void push(Object x); /** * precondition: stack is [e1, e2, ..., en] with n >= 1 * postcondition: stack is [e1, e2, ..., e(n-1)]; returns en * exceptions: throws an unchecked exception if the stack is empty */ Object pop(); /** * precondition: stack is [e1, e2, ..., en] with n >= 1 * postcondition: returns en * exceptions: throws an unchecked exception if the stack is empty */ Object peekTop(); }