For this project you are going to create the game hangman. Hangman is a simple word game where the player attempts to guess a word before they get "hung" by guessing letters that they think might be in the word. Your program should begin by reading words from a file and then choosing one of them to be the random word which the user will try to guess. Allow the user to guess letters one at a time until they get the word or guess incorrectly 6 times. Have an interface which looks similar to the one below: see image.
As the player makes guesses update the display accordingly. When the player misses draw a new part of the person hanging from the gallows. Here is an example: see image.
In this case the right arm would have just been drawn because of the fourth miss. When the player gets a letter correct you should update the blank where that letter occurs to show where it goes (as was the case with s and n in the example above). When the game ends tell what the word was and whether or not the player won. Here is an example: see image.
When the game ends give the user the option of playing again. The word should be different each time the game is played.
Your program should tell the user how many letters are in the word by showing the appropriate number of blanks for each word.
Your program should read a file with at least 10 words in it (one word per line) called "words.txt". The length of these words will be no more than 20 characters and there should be no more than 50 words in a file. You program should only read this file once when it starts, and then select a new word from this list each time the player plays the game so that the words will be different. You can assume that there will be no more than 50 words in the file.
Since we are trying to learn about object-oriented programming you need to write at least three classes for this project: Gallows, Word and Blanks.
The Gallows class should have one attribute, an integer called misses. This class should have a constructor and set and get methods for misses. Additionally, you will need a draw method for the gallows class which draws the gallows appropriately based on the number of misses (how many incorrect letters the user has guessed).
The Word class should have one attribute, a string called str. This class should have a constructor and set and get methods for str. Additionally, you should write a functionality method for this class called find Letter which takes a parameter of type char and returns a bool. Here is the prototype: bool find Letter(char c); This method searches through str for an occurrence of c. If c is found in str, then true is returned. Otherwise, false is returned.
The Blanks class is used to handle the printing of the appropriate number of blanks to the screen. You have some freedom in designing this class, but I suggest that you put two attributes into it: one, a character array, that stores the right number of blanks; and the second, an integer, that stores how many blanks there should be. There are several possibilities for functionality methods in this class that would make the project easier to write.
You should use appropriate commenting and indentation in your code, as discussed in class. Make sure your name is in comments at the top of your code. If this is not done, then expect significant points to be deducted from your program.
You are not allowed to use GLOBAL VARIABLES.
This program is not long, but it is probably more complicated than it may initially seem. GET STARTED EARLY!!!
Additional code
1. Write a fourth class called Guesses to keep track of the letters guessed by the player. The letters guessed should be displayed before each guess to help players remember what they have tried.