/** play a game of hangman.
 */
import java.io.*;
public class Hangman {
  private static BufferedReader in;
  public static void main(String[] args) throws IOException {
    // Set up a WordList, TargetWord, BufferedReader
    // and a Hangman to make guesses.
    WordList wL= new WordList("gone with real ogre fits ");
    TargetWord tW= new TargetWord(wL.select());
    Hangman hM= new Hangman();
    in= new BufferedReader(new InputStreamReader(System.in));

    // Cycle through 10 guesses	
    hM.makeGuess(tW);
    hM.makeGuess(tW);
    hM.makeGuess(tW);
    hM.makeGuess(tW);
    hM.makeGuess(tW);
    hM.makeGuess(tW);
    hM.makeGuess(tW);
    hM.makeGuess(tW);
    hM.makeGuess(tW);
    hM.makeGuess(tW);

    // Tell the user whether they've won:
    System.out.println("Did you guess it? " + tW.allGuessed());
  }

  /** makeGuess: a helper method that prompts the user for a
   *  guess, then tries it out.
   */
  private void makeGuess(TargetWord tw) throws IOException {
    System.out.println("\nGuess a character");
    String guessedChar= in.readLine();
    tw.guess(guessedChar);
    System.out.println(tw);
  }
}


