class PileException extends Exception {
  PileException(String m) {
    super(m);
  }
}

interface Pile {
  boolean isEmpty();
  boolean isFull();
  void push(Object x) throws PileException;
  Object top() throws PileException;
  void pop()  throws PileException;
}

class ListePile implements Pile {
  class Liste {
    Object contenu;
    Liste suivant;
    Liste(Object contenu, Liste suivant) {
      this.contenu = contenu;
      this.suivant = suivant;
    }
  }
  private Liste tete = null;

  public boolean isEmpty() {
    return tete == null;
  }

  public boolean isFull() {
    return false;
  }

  public void push(Object x) throws PileException {
    tete = new Liste(x, tete);
  }

  public Object top() throws PileException {
    if (isEmpty())
       throw new PileException("Pile vide");
    return tete.contenu;
  }

  public void pop()  throws PileException {
    if (isEmpty())
       throw new PileException("Pile vide");
    tete = tete.suivant;
  }
}

