// Automate.java

public class Automate {
   private Etat initial, dernier;

   Automate() {
      this.initial = new Etat();
   }

   public Etat getInitial() {
      return this.initial;
   }

   public Etat getDernier() {
      return this.dernier;
   }

   public Etat getCibleParSuppleance(Etat p, Lettre a) {
      while (p != null && p.getCible(a) == null)
         p = p.getSuppleant();
      if (p == null)
         return this.getInitial();
      else
         return p.getCible(a);
   }

   public void ecrire () {
      this.getInitial().ecrireAutomate();
      this.getInitial().ecrire();
   }
}