// Etat.java import java.util.Enumeration; import java.util.Hashtable; public class Etat { private static int compteur = 0; private Hashtable succ; private Etat suppleant; private boolean terminal; private int nom, sortie; private static boolean[] visite; Etat() { this.succ = new Hashtable(); this.nom = Etat.compteur++; this.terminal = false; } public int getSortie() { return this.sortie; } public void setSortie(int sortie) { this.sortie = sortie; } public Etat getLs() { return this.suppleant; } public void setLs(Etat p) { this.suppleant = p; } public Etat getSuppleant() { return this.suppleant; } public void setSuppleant(Etat p) { this.suppleant = p; } /* public void setCible(Lettre a, Etat q) { this.succ.put(a, q); } */ public void setCible(Lettre a, Etat q) { Lettre b; Enumeration e = this.succ.keys(); while (e.hasMoreElements()) { b = (Lettre)e.nextElement(); if (a.equals(b)) this.succ.remove(b); } this.succ.put(a, q); } /* public Etat getCible(Lettre a) { return (Etat)this.succ.get(a); } */ public Etat getCible(Lettre a) { Lettre b; Enumeration e = this.succ.keys(); while (e.hasMoreElements()) { b = (Lettre)e.nextElement(); if (a.equals(b)) return (Etat)this.succ.get(b); } return null; } public int getNom() { return this.nom; } public void copieCibles(Etat q) { this.succ = (Hashtable)q.getSucc().clone(); } public Hashtable getSucc() { return this.succ; } public void setTerminal(boolean b) { this.terminal = b; } public void ecrireAutomate() { this.visite = new boolean[this.compteur]; } public void ecrire() { Etat q; Lettre a; if (!this.visite[this.nom]) { this.visite[this.nom] = true; System.out.println("Etat : "+this.nom); Enumeration e = this.succ.keys(); while (e.hasMoreElements()) { a = (Lettre)e.nextElement(); q = (Etat)this.succ.get(a); System.out.println(" delta("+this.nom+","+a+") = "+q.getNom()); q.ecrire(); } } } }