## Hangman

Today you'll make everybody's favorite pretty-grisly-is-this-actually-appropriate?-children's game Hangman. Before you start, create a directory called lab08, and download this tarball of wordlists to it. Untar it with the command tar xzf words.tgz.

Below is an example of my program running:

taylor@kurt:~/zee/si204/class/lab08\$ ./a.out

What file do you want a word from? words07.txt

-------.  6 wrong guesses left.
Enter a guess: e
No E.

-------.  5 wrong guesses left.
Enter a guess: r
No R.

-------.  4 wrong guesses left.
Enter a guess: a
Yes!  There is a A.

-A---A-.  4 wrong guesses left.
Enter a guess: s
No S.

-A---A-.  3 wrong guesses left.
Enter a guess: g
Yes!  There is a G.

-A-G-A-.  3 wrong guesses left.
Enter a guess: n
Yes!  There is a N.

-ANG-AN.  3 wrong guesses left.
Enter a guess: f
No F.

-ANG-AN.  2 wrong guesses left.
Enter a guess: k
No K.

-ANG-AN.  1 wrong guesses left.
Enter a guess: h
Yes!  There is a H.

HANG-AN.  1 wrong guesses left.
Enter a guess: b
No B.

You lose...  The word was HANGMAN.

Of course, if I fill in the entire word before I run out of guesses, I win, instead.

To help you write this program, write the following methods in a file called hangman.cpp:

• char getGuess() - Prompts the user for a guess - if lower-case, it makes it upper-case. If not a letter, keeps asking until it is. Then returns the capital letter.
• string makeCapital(string s) - Takes in a string, and returns a string with all letters made capital. As an example, makeCapital("hEllO") would return the string "HELLO".
• bool makeChanges(string& blank, string full, char c) - "full" is the string to be guessed ("HANGMAN" in the above example). "blank" is the string with hyphens at unguessed letters and letters where guessed (in the above example, after two guesses, "HA---A-"). "c" is the character that has just been guessed. If that letter appears in the word, the appropriate hyphens are changed to the letters, and the function returns true. If no changes are made to blank, the function returns false.
• bool isDone(string s) - returns true if there are no hyphens in s, and false otherwise.
• string pickWord(string filename) - randomly picks a word from the input filename (such as words09.txt) and returns it. To do this, you'll need to use rand() to pick a random number between 0 and the number of words in the file.

Once you have these methods, you can hopefully write a main function to implement the full game. Feel free to write any other functions you think would be helpful to you.

It is necessary that your first user input be a filename to draw a random word from, and the remainder of user inputs be letters guessed. Each turn, you should display the blanked-out word, and the number of wrong guesses remaining. At the end of the game, you should display if the player won. Aesthetic decisions are up to you.

## Extra challenge

The only thing we haven't done is draw the little man. Rather than having a countdown with the number of guesses remaining, draw the man! To get you started, here's a string that gives you the full hanging man:

  string fh = "  ____\n  |   |\n _O_  |\n  |   |\n / \\  |\n______|_\n";

And here's a string that gives you an empty gallows:

  string ch = "  ____\n  |   |\n      |\n      |\n      |\n______|_\n";

## Submission

If in Dr. Taylor's sections, submit with submit lab08

If in Dr. Chambers' secion, submit with submit lab08 hangman.cpp