wrinnix (1) Apr 24, 2010 at 3:09pm
I really need help with this project. I do not know where to begin at all.
Below are the instructions from the teacher any and all help would be appreciated.
Write a program that plays the game of Hangman. The program should pick a word (which is coded
directly into the program) and display the following:
Guess the word: xxxxxx
Each x represents a letter. The user tries to guess the letters in the word. The appropriate response yes
or no should be displayed after each guess. After each incorrect guess, display the disagram with another
body part filled. After seven incorrect guesses, the user should be hanged. The display should look as
follows:
O
/ | \
|
/ \
After each guess, display all guesses. If the user guesses the word correctly, the program should display
Congratulations! You guessed the word…play again? Yes/No
I wonder... When u see a double post, is commenting on both posts about double posting considered a double post?... :D
Anyway, to help the OP get started I would suggest the following:
-> Use std::string to hold the current word being guessed.
-> Maybe you want to use a const std::string array to hold a list of words from which you choose a random one (see cstdlib rand() and srand() functions) every time the user plays a new game.
-> A good way to implement the guessing process would be a loop (while/for).
-> You can use a std::vector<char> to hold the letters so far entered by the user and not existing in the word to guess and another one (std::vector<char>) to hold the ones entered and existing in the word to guess.
-> If you are not familiar with the things mentioned above you can take a look at: