import java.util.Scanner;

public class Appli {
	public static void afficher(Pendu p) {
		String s = "";
		for (int i = 0; i < FonctionsPendu.longueurMotATrouver(p); ++i) {
			if (FonctionsPendu.estTrouvée(p, i))
				s += FonctionsPendu.lettre(p, i);
			else
				s += "_";
		}
		s += ", " + FonctionsPendu.nbErreurs(p) + " erreur(s)";
		System.out.println(s);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		System.out.print("Entrez le mot à découvrir : ");
		String m = sc.next();
		Pendu p = new Pendu();
		FonctionsPendu.init(p, m);
		while (!FonctionsPendu.fini(p)) {
			afficher(p);
			System.out.print("Entrez une lettre : ");
			char c = sc.next().charAt(0);
			FonctionsPendu.jouer(p, c);
		}
		if (FonctionsPendu.gagné(p))
			System.out.println("Bravo");
		else
			System.out.println("Perdu, il fallait trouver '" + m + "'");
		sc.close();
	}
}
