{
myFile >> allWords[index].word;
allWords[index].length = allWords[index].word.length();
allWords[index].used = false;
allWords[index].solved = false;
index++;
}
}
else
{
cout << "Can't open file ";
}
for( int i = 0; i < index; i++)
cout << allWords[i].word << " ";
return index;
cout << endl << endl;
}
These are the instructions that I have.
Programming Requirements:
1. Display title screen.
2. Read up to 50 words from a file into an appropriate data structure.
3. Randomly select a word for the game from the data structure.
4. Display the game word, letter list and the Hangman gallows.
5. Allow the user to choose a letter and mark the letter as used.
6. If the letter is in the word, reveal the letter in the game word. If the letter is not in the word,
add a body part to the gallows.
7. Track the number of guesses in the game. Once the player has missed a total of 6 letters the
game is over (gallows should display a full body) and a losing message should be displayed.
8. If the word is fully revealed before 6 guesses the player should be congratulated for the win.
9. Following either a win or lose the player is prompted to play another game.
10. If the player chooses to play again, the game selects a different word reinitializes the display
(empty gallows, all letters are displayed, game word is represented by "_" or other such
characters).
11. If the player chooses not to play again display a credit screen.
I have the same assignment It's due today I think, and I'm pretty sure that I'm screwed. I cant figure it out, but Good luck to you. You may be fortunate enough to get it.
Okay, so here's what you can do..
1) You can select a random word using the rand() function...
2) When the user enters a letter, you search the game word for the letter, using either a custom string search function, or strtok... Also, have an array of all the 26 letters, say char alpha[26], having alpha[1]=a; alpha[2]=b;, and so on... use the tolower function in case the user has CAPSLOCK on...
When the user enters a letter that is there in the game word, access that array element and replace it with a "_"...
3) You can make a function, that checks for the number of wrong guesses till the point, and accordingly prints some ASCII Hangman pic(Use your imagination!)... Have 6 levels of this pic, depending on number of wrong guesses..
4) Put the entire game in a do-while loop... Ask whether the user wants to play again, and accordingly re-iterate or quit the loop.
5) Keep a printnext kind of function which scans the progress of the game after each input of letter, and accordingly prints the next screen (for example, strike out the guessed letter, print the next level of the hangman gallows if wrong guess, etc...)