my friend and i are working on a hangman project for our C++ class and when our professor tells us to do something it sort of comes out like gibberish. he told us that we need to concatenate one part of our code so that we can cast a character into a string so that the guess letter is turned into a string so that we can add the string garbage guess collector and the guess letter together. but the problem is we don't know how to do this. if someone could help a couple of lost girls that would be wonderful. and if you could phrase it in a way that we could actually understand that would be even better.
here is our code....:
/* determine game status */
// check if all letters are shown then you win
if(Secret_Word == Masked_Secret_Word)
{
Won_the_Game_Display();
cout << "Secret Word" <<endl <<endl;
cout << "You Won!!!" <<endl <<endl;
Game_Still_Playing = false;
}//if won
// you lost the game
else if( Mistake_Counter >= 5 )
{
cout << "Secret Word" << Secret_Word <<endl <<endl;
cout << "You Lost Sucka!!" <<endl <<endl;
//Stop the Game
Game_Still_Playing = false;
}//else if lost
// else still playing the game
else
{
// display the bad guesses made thus far in the game
cout << "Please enter guess letter" <<endl <<endl;
cin >> A_Guess_Letter;
// show gallow screen
Display_Current_Gallows_Picture(0);
// show the greeting and rules
cout << "Welcome to the game!" <<endl <<endl;
cout << "The game is simple. You will be shown a word that is masked with question marks, and it will be your job to guess the letter that will reveal a letter within the mask word." <<endl <<endl;
cout << "If the letter you guessed is correct it will be revealed. If not, then you will become one step closer to losing" <<endl <<endl;
// gather the secret word
cout << "Please enter Secret Word, then press Enter" <<endl <<endl;
//put secret word into memory
m_w = Some_Secret_Word;
cin >> Some_Secret_Word;
return;
}// end procedure
void Mask_The_Secret_Word(string& m_w)
{
//local variables
int index = 0; // used to walk arrays
int length_of_word = m_w.length();
char mask_symbol = '?'; // used as the symbols in the masked array
/* start */
// get a copy of the secret word for processing as character array
// make the masked version of the secret_word string
// it will double the size of the string
for(index = 0; index = length_of_word; index++)
{
// the insert will put all the needed masking symbols in the
// front half of the array, and leave the unmasked letters in the back half
m_w[index]= '?';
}//end forloop
return;
}//end procedure
// cut the string in half, keep the front half that contains masked symbols //
/* discard the back half that holds the unmasked letters
"index" is holding where to start removing and "secret_word_string_length" is how many to remove */
/* start */
switch(mistake_counter)
{
case 0: Show_No_Mistakes();
break;
case 1: One_Mistake_Made();
break;
case 2: Two_Mistakes_Made();
break;
case 3: Three_Mistakes_Made();
break;
case 4: Four_Mistakes_Made();
break;
case 5: Five_Mistakes_Made();
break;
case 6: Won_the_Game_Display();
break;
return;
}//end switch
return;
}// end procedure
//new procedure
void Get_A_Guess_Letter_And_Test_It(string secretword_holding_correct_letters, string& word_to_unmask, int& mistake_counter, string& bad_guess_container)
{
//local variables
int length_of_word = secretword_holding_correct_letters.length(); // stopping condition in forloop
int index = 0; // index of forloop
bool guess_letter_was_found = false; // stores if guess letter is found
char a_guess_letter = ' ' ;
/* start */
// get a letter to guess with
// walk the secret word string to try and find the guess letter
// if the guess letter is found, report this
index = 0;
for(index = 0; index = length_of_word; index++)
{
// check current secret word letter with the guess letter
if(secretword_holding_correct_letters[index] == a_guess_letter)
{
// echo how many found
}//end if found
}//end forloop
// check if guess letter was found and try to unmask the the letters
if(guess_letter_was_found)
{
// reset data structure controlers for the next phase of processing
index = 0;
// compare the guess letter with each member of the secret word string
// when a match is found, change that value in the masked word string
// to the value of the guess letter
for(index = 0; index = length_of_word; index++)
{
// update the mask string and the win counter for every find
if( secretword_holding_correct_letters[index] == a_guess_letter )
{
//echo how many found
}//end where found
}//end forloop
}// end if found
// else update which gallow picture must be shown as a mistake
******help in this area too??
// reset the guess letter memory storage to blank