Hangman

Short Description:

Implement the game of Hangman

This assignment is worth 0 points.

Goals

When you finish this homework, you should:

Formal Description

The game of hangman is played between two players, let's call them a judge and a suspect. The judge selects a word (or phrase) and tells the suspect how many letters are in the word. The suspect then tries to figure out the word by guessing letters. Each time the suspect guesses a correct letter, all of the occurrences of this letter are displayed, in the proper position. If the suspect guesses an incorrect letter, the judge adds another part to a picture of the suspect who is to be hanged on the gallows.

The figure displayed is as follows:
Incorrect Guess Number Body Part AddedSymbol
1 Head 0
2 Left Arm \
3 Right Arm /
4 Torso |
5 Left Leg /
6 Right Leg \

The final figure, if the suspect loses will be

\0/
 |
/ \
For this game, your program will assume the role of the judge, and the user will be the suspect. Since your program can not "think" of a word or phrase, the data will be stored in a file, phrases.txt. The data will be stored one entry per line and can include spaces. This file contains at least one valid data entry. Assume the first word in the file is Hangman.

The judge should begin by presenting the suspect with a picture of the gallows, blanks for each letter in the word, and current conditions, such as the turn, the letters guessed which were incorrect, and other information. The following is an example for the output. Your output need not match exactly, but should be similar.

 +--+
 |
 |
 |
 |
++++++++      _ _ _ _ _ _ _

Turn: 1
Incorrect Letters: 

Guess a letter: => E
Your guess of E is incorrect.
Added Head!


 +--+
 |  0
 |
 |
 |
++++++++      _ _ _ _ _ _ _

Turn: 2
Incorrect Letters: E
Guess a letter: => t
Your guess of T is incorrect.
Added Left Arm!


 +--+
 | \0
 |
 |
 |
++++++++      _ _ _ _ _ _ _

Turn: 3
Incorrect Letters: E,T
Guess a letter: => A
There are 2 of the letter A


 +--+
 | \0
 |
 |
 |
++++++++      _ A _ _ _ A _

Turn: 3
Incorrect Letters: E,T
Guess a letter: => 
The program should proceed in this manner until either the suspect figures out the word, or has six incorrect guesses. The player is either pronounced the winner, or given the answer to the puzzle. Finally they are asked to play again, and the process in repeated.

When the player declines to play again, they are given their score (m wins and n losses) and thanked for playing.

Discussion

Required Files

You should not submit

Submission

Email your source code to danbennett360@gmail.com by class time of the due date.