Question: I need to implement a CLASS or CLASSES in this C++ code, or transform the whole code with the use of classes. #include #include #include
I need to implement a CLASS or CLASSES in this C++ code, or transform the whole code with the use of classes.
#include
using namespace std;
const int MAX_TRIES=5; int letterFill (char, string, string&);
int main (){ string name; char letter; int num_of_wrong_guesses=0; string word; string words[] ={ "india", "japan", "nepal", "china", "madagascar", "azerbaijan", "kyrgyzstan", "turkmenistan", "french guiana", "caledonia" };
//choose and copy a word from array of words randomly int n=rand()% 10; word=words[n]; // Initialize the secret word with the * character. string unknown(word.length(),'*'); // welcome the user cout > letter; // Fill secret word with letter if the guess is correct, // otherwise increment the number of wrong guesses. if (letterFill(letter, word, unknown)==0){ cout
/* Take a one character guess and the secret word, and fill in the unfinished guessword. Returns number of characters matched. Also, returns zero if the character is already guessed. */ int letterFill (char guess, string secretword, string &guessword){ int i; int matches=0; int len=secretword.length(); for (i = 0; i
/* OUTPUT:
Welcome to hangman!! Guess a country that comes into your mind.
Each letter is represented by an asterisk.
You have to type only one letter in one try.
You have 5 tries to try and guess the country. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*****
Guess a letter: q
Whoops! That letter isn't in there! You have 4 guesses left.
*****
Guess a letter: w
Whoops! That letter isn't in there! You have 3 guesses left.
*****
Guess a letter: e
Whoops! That letter isn't in there! You have 2 guesses left.
*****
Guess a letter: r
Whoops! That letter isn't in there! You have 1 guesses left.
*****
Guess a letter: t
Whoops! That letter isn't in there! You have 0 guesses left.
Sorry, you lose...you've been hanged. The word was : japan */




![string words[] ={ "india", "japan", "nepal", "china", "madagascar", "azerbaijan", "kyrgyzstan", "turkmenistan", "french](https://s3.amazonaws.com/si.experts.images/answers/2024/08/66acaed34bd2f_97866acaed2e8942.jpg)
include #include #include #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
