// File Stack.java
// Henry H. Leitner
// This example implements a "Stack" using
//  "composition" -- i.e., a vector containing
//  the stack items is an instance variable

import java.util.Vector;

class Stack
{
  private Vector<Object> theData;

  public Stack()
  {
     theData = new Vector<Object>(); 
  }

  public boolean isEmpty()
  {
     return theData.isEmpty();
  }

  public Object push (Object item)
  {
     theData.addElement(item);
     return item;
  }

  public Object peek()
  {
     return theData.lastElement();
  }

  public Object pop ()
  {
     Object result = theData.lastElement();
     theData.removeElementAt(theData.size()-1);
     return result;
  }
}
