// Non-empty stacks. // // For purpose statements and algebraic specification, see Stack.java. class Push extends StackBase { Stack s; // the other elements of this Stack E x; // the topmost element of this Stack Push (Stack s, E x) { this.s = s; this.x = x; } public Stack push (E x) { return new Push (this, x); } public boolean isEmpty () { return false; } public E top () { return x; } public Stack pop () { return s; } public int size () { return 1 + s.size(); } }