public class Stack1 implements Stack{
  int max;
  int size;
  Object[] dati;
public Stack1(int dim){
  dati = new Object[dim];
  max = dim;
  size = 0;
}
public void push(Object o)
 throws StackException 
{
  if(size == max)
    throw new StackException("massimo dello stack superato");
  dati[size++] = o;
 
 }

public Object pop()
 throws StackException 
{
 if(size <=0) 
  throw new StackException("stack vuoto");
 return dati[--size];
}

public Object top()
 throws StackException 
{
 if(size <=0) 
  throw new StackException("stack vuoto");
 return dati[size-1];
}

public int size(){return this.size;}
}
