public class StackADT1<T>
{
	/*Uses generics
	 * requires a special form for instantiation of an array
	 */
	 
	 private int position, capacity;
	 private T[] stack;
	 
	 public StackADT1(int n)
	 {
	 	capacity = n;
	 	stack = (T[]) new Object[n];
	 	//stack = new T[n]; doesn't work
	 	position = -1;
	 }
	 
	public  void push(T token)
	{
	/*
	 * pre: stack is not full
	 */
	    position++;
	    stack[position] = token;
    }
    
    public  T pop()
	{
	/*
	 * pre: stack is not empty
	 */
	    T temp = stack[position];
	    position--;
	    return temp;
    }
    
    public boolean isFull()
    {
    	return capacity - 1 == position;
    }
    
    public boolean isEmpty()
    {
    	return position == -1;
    }
    
    public T peek()
    {
    	return stack[position];
    }
}
