/*
 * Stack.java
 *
 * Version:
 *    $Id: Stack.java,v 1.1.1.1 2002/09/25 11:41:52 ptt Exp $
 *
 * Revisions:
 *    $Log: Stack.java,v $
 *    Revision 1.1.1.1  2002/09/25 11:41:52  ptt
 *    Initial Commit
 *
 */

import java.util.EmptyStackException;

/**
 * An abstract base class for a Stack.
 *
 * @author     Paul Tymann
 */

abstract class Stack {

    // Count of the number of items in the stack.

    protected int count = 0;

    /**
     * Push an object on top of the stack.
     *
     * @param obj a reference to the object to be placed on top of
     *            the stack.
     */

    public abstract void push( Object obj );

    /**
     * Remove the top element from the stack.
     *
     * @throws EmptyStackException if the stack is empty.
     */

    public abstract void pop() throws EmptyStackException;

    /**
     * Return a reference to the object currently on top of the stack.
     *
     * @return a reference to the item on top of the stack.
     *
     * @throws EmptyStackException if the stack is empty.
     */

    public abstract Object top() throws EmptyStackException;

    /**
     * Check to see if there are any elements in the stack.
     *
     * @return true if there are elements in the stack and false otherwise.
     */

    public boolean isEmpty() {
	return count==0;
    }

} // Stack

