public class StackADT
{
    /*
     * a Abstract Data type implementation of a stack for Object
     */
	 
    private int position, capacity;
    private Object[] stack;
	 
    public StackADT(int n)
    {
	capacity = n;
	stack = new Object[n];
	position = -1;
    }
	 
    public  void push(Object token)
    {
	/*
	 * pre: stack is not full
	 */
	position++;
	stack[position] = token;
    }
    
    public  Object pop()
    {
	/*
	 * pre: stack is not empty
	 */
	Object temp = stack[position];
	position--;
	return temp;
    }
    
    public boolean isFull()
    {
    	return capacity - 1 == position;
    }
    
    public boolean isEmpty()
    {
    	return position == -1;
    }
    
    public Object peek()
    {
    	return stack[position];
    }
    
    public String toString() {
	String str = "I am a StackADT object with contents ";
	for (int i = 0; i <= position; i++) {
	    str += " " + stack[i];
	}
	return str;
    }
}

