Question: Write a C++ hangman game using at least 5 user defined functions. The secret hangman word will come from an input file. I cannot use

Write a C++ hangman game using at least 5 user defined functions. The secret hangman word will come from an input file. I cannot use any arrays or vectors, this must be accomplished with loops

Function 1 should prompt user for game number. If the user types "3" then the third word in the file will be used.

Function 2 should read the word from an input file. If the game number chosen from function 1 is less than zero then a randomly selected word will be used.

Function 3 will print the correct hangman picture based on the number of wrong guesses. See below for example of hangman picture

Function 4 will make a copy of the secret word and replace all letters with ***** then print

Function 5 will allow the user to make the next guess and change the **** to letters if a correct letter is chosen

These are basic guidelines, some variation is okay

hangman looks somethin like this:

void printHangman(int wrongGuesses )

{

if (wrongGuesses == 6)

{

cout << endl << endl

<< " -------- " << endl

<< " | O " << endl

<< " | /|\\ " << endl

<< " | / \\ " << endl

<< " | " << endl;

}

else if (wrongGuesses == 5)

{

cout << endl << endl

<< " -------- " << endl

<< " | O " << endl

<< " | /|\\ " << endl

<< " | / " << endl

<< " | " << endl;

}

else if (wrongGuesses == 4)

{

cout << endl << endl

<< " -------- " << endl

<< " | O " << endl

<< " | /|\\ " << endl

<< " | " << endl

<< " | " << endl;

}

else if (wrongGuesses == 3)

{

cout << endl << endl

<< " -------- " << endl

<< " | O " << endl

<< " | /| " << endl

<< " | " << endl

<< " | " << endl;

}

else if (wrongGuesses == 2)

{

cout << endl << endl

<< " -------- " << endl

<< " | O " << endl

<< " | | " << endl

<< " | " << endl

<< " | " << endl;

}

else if (wrongGuesses == 1)

{

cout << endl << endl

<< " -------- " << endl

<< " | O " << endl

<< " | " << endl

<< " | " << endl

<< " | " << endl;

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!