package examples.stack1;
/**
* Author: W. M. Farmer
* Revised: February 11, 2007
*
* Description: A definitional extension of Stack.
*/
public class StackPlus extends Stack {
/**
* Mutator that changes the top element of the stack.
*
* @param element the new top element
*/
public static void setTop(int element) {
pop();
push(element);
}
/**
* Mutator that empties the stack.
*/
public static void reset() {
while (height() != 0) {
pop();
}
}
/**
* Predicate that checks if the stack is empty.
*
* @return true iff the stack is empty
*/
public static boolean isEmpty() {
return height() == 0;
}
}