Concrete Class for Empty Stacks
// Empty stacks. // // For purpose statements and algebraic specification, see Stack.java. public class EmptyStack<E> extends StackBase<E> { public EmptyStack () { } public Stack<E> push (E x) { return new Push<E> (this, x); } public boolean isEmpty () { return true; } public E top () { String msg1 = "attempted to compute the top of an empty StackInt"; throw new RuntimeException (msg1); } public Stack<E> pop () { return this; // FIXME: this is evil } public int size () { return 0; } }
If the video above doesn't work for you, try this link instead.