import java.util.Vector;
public class VectorStack
implements StackInterface{
private Vector stack; // top of stack is the
last item in the vector
public
VectorStack() {
stack
= new Vector();
}
public
VectorStack( int maxStack) {
stack
= new Vector(maxStack);
}
public
void push(Object newEntry)
{
stack.addElement(newEntry);
} // end push
public
Object peek()
{
Object top =
null;
if (!isEmpty())
top = stack.lastElement();
return top;
} // end peek
public
Object pop()
{
Object top =
null;
if (!isEmpty())
{
top = stack.lastElement();
stack.removeElementAt(stack.size()-1);
} // end if
return top;
} // end pop
public
boolean isEmpty()
{
return stack.isEmpty();
} // end isEmpty
public
void clear()
{
stack.removeAllElements();
} // end clear
}