Answer to Question #3700 in C++ for Chibzy

Question #3700
In this assignment you will create a “hangman” game, putting into the practice almost all of the topics we have discussed in the course. Due the size of the assignment I’m calling it a “project” and giving you until the end of the course to complete. If you complete it successfully then you will have come away from this course with a good foundation in programming C++. Most people are already familiar with the game of hangman, but in case you aren’t, a player guesses letters of a hidden word, and each time a wrong guess is made, another limb of the “hangman” is drawn until the full figure is drawn and the player loses or all the letters are revealed and the player wins. Since we only have console output, you will need to use ASCII characters to draw the man, and the example output below gives you each stage that you can use. Or you can be creative and come up with your own hangman drawing. If you use mine, the player will have 7 wrong guesses before the hangman is drawn and the player loses. The first thing your program must do when it starts is read in a list of words from a file called words.txt. The words must be read into an array of strings. You can assume the word list will not have more than 50 words. Then each time a new game begins, select one of the words randomly. To do that, choose a random number from 0 to the number of words read in minus 1, and pick the word at that element. Here is a sample word list you can use: BUTTERFLY INDONESIA ALLIGATOR PROGRAMMING ROTISSERIE PICNIC GENTLEMAN KEYBOARD KANGAROO GEOGRAPHY INDICATION KITCHENER Once a word is selected, you need to keep track of two things. First, you need to remember what letters have been guessed correctly so you know which letters to reveal and which to hide. The hidden letters should be represented with an underscore. One space must be between each letter or underscore when displaying on the screen or else it will be hard to see how many letters are in the word. You also need to know what letters are still available. When a game starts, all 26 letters are available. As letters are guessed, you must remove that letter from “available” string. You can do that using find or the ASCII value. For each try, always show the player what letters are still available. There are several approaches you can take to achieving the above two tasks, and I leave it up to you to be innovative in your solution. When a letter guess is made you will check for several things. First, if the letter has already been guessed, indicate that and treat it as though they chose a wrong letter (punishment for their carelessness!). Second, if the letter exists in the word, you need to indicate how many times it exists, since it could be in the word more than once. If the letter does not exist in the word, indicate that and increment the number of wrong guesses. Each try draw the parts of the hangman corresponding to the number of wrong guesses made so far. If you use my ASCII hangman art, there are 7 wrong guesses before the hangman is drawn. If your game and hangman output has a different maximum number of wrong guesses that is OK too. You need to know if all of the letters have been guessed. If so, indicate the player has won. If the hangman has been fully drawn (maximum number of wrong guesses has occurred), the player has lost. At the end of each game you must ask if the play would like to play again. If not, display how many games they won and how many they lost. Here is sample output from my hangman game. Like I said earlier, you can reuse my ASCII hangman drawings or you can use your own. Welcome to C++ Hangman! +----+ | | | | | | | --- The word is: _ _ _ _ _ _ _ _ _ _ _ Letters left: ABCDEFGHIJKLMNOPQRSTUVWXYZ What is your guess? T Nope, there is no T in the word! +----+ | | | O | | | | --- The word is: _ _ _ _ _ _ _ _ _ _ _ Letters left: ABCDEFGHIJKLMNOPQRSUVWXYZ What is your guess? S Nope, there is no S in the word! +----+ | | | O | | | | | --- The word is: _ _ _ _ _ _ _ _ _ _ _ Letters left: ABCDEFGHIJKLMNOPQRUVWXYZ What is your guess? A Yes, there is one A in the word! +----+ | | | O | | | | | --- The word is: _ _ _ _ _ A _ _ _ _ _ Letters left: BCDEFGHIJKLMNOPQRUVWXYZ What is your guess? E Nope, there is no E in the word! +----+ | | | O | \| | | | --- The word is: _ _ _ _ _ A _ _ _ _ _ Letters left: BCDFGHIJKLMNOPQRUVWXYZ What is your guess? M Yes, there are 2 M's in the word! +----+ | | | O | \| | | | --- The word is: _ _ _ _ _ A M M _ _ _ Letters left: BCDFGHIJKLNOPQRUVWXYZ What is your guess? B Nope, there is no B in the word! +----+ | | | O | \|/ | | | --- The word is: _ _ _ _ _ A M M _ _ _ Letters left: CDFGHIJKLNOPQRUVWXYZ What is your guess? C Nope, there is no C in the word! +----+ | | | O | \|/ | | | | --- The word is: _ _ _ _ _ A M M _ _ _ Letters left: DFGHIJKLNOPQRUVWXYZ What is your guess? R Yes, there is one R in the word! +----+ | | | O | \|/ | | | | --- The word is: _ R _ _ _ A M M _ _ _ Letters left: DFGHIJKLNOPQUVWXYZ What is your guess? R Hey, you already guessed that! +----+ | | | O | \|/ | | | / | --- The word is: _ R _ _ _ A M M _ _ _ Letters left: DFGHIJKLNOPQUVWXYZ What is your guess? L Nope, there is no L in the word! +----+ | | | O | \|/ | | | / \ | --- YOU LOSE!!! Play again? (Y or N): N You won 0 games and lost 1 game. Thanks for playing!
Expert's answer
Unfortunately, your question requires a lot of work and cannot be done for free. Submit it with all requirements as an assignment to our control panel and we'll assist you.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog