Please write in visual studious for c Hangman Create a twope

Please write in visual studious for c++.

Hangman Create a two-person version of Hangman (word-guessing game). The game begins with one player entering a secret word. The secret word is then scrolled off the screen before the other player sits down to play. A blank guess template then appears on the screen. This template is the same length as the secret word, but has dashes in place of the letters in the word. The player attempting to guess the secret word enters letters one at a time. After each guess, the guess template is updated to show which letters in the secret word match the letter guessed (if any). For example, if the secret word is \"poodle\", guessing the letter p results in the following changes in the guess template. Enter the secret word: pool (this scrolls off the screen) Guess a letter: p Guess a letter: o Guess a letter: You guessed the word in 5 guesses Program requirements: Create functions for creating the template and updating the template. You may use c-strings or the C++ string data type

Solution

/*
Simple hangman game
Do not use caps
*/

#include <iostream>
#include <string>
using namespace std;

int main()
{
cout << \"Enter the word for other player to guess\" << endl;
  
string word;
getline(cin, word);
  
string copy = word;

string Underscore;
  
for(int i=0; i!=word.length(); i++){

if(word.at(i) == \' \'){
Underscore += \" \";
} else{
Underscore += \"_\";
}
}
  
for(int i=0; i!=50; ++i){
cout << endl;
}
  
string guess;
int wrong=0;
  
while(1){
if(wrong == 6){
cout << \"You Lose! The word was: \" << word << endl;
break;
}

cout << Underscore << endl;
cout << \"There are \" << word.length() << \" letters with spaces\" << endl;
cout << \"You have \" << 6 - wrong << \" more tries left\" << endl;

if(Underscore == word){
cout << \"You win!\" << endl;
break;
}

cout << \"Guess a letter or a word\" << endl;
getline(cin, guess);
  
if(guess.length() > 1){
if(guess == word){
cout << \"That\'s right, you win!\" << endl;
break;
} else{
cout << \"wrong word \" << endl;
wrong++;
}
} else if(copy.find(guess) != -1){
while(copy.find(guess) != -1){
Underscore.replace(copy.find(guess), 1, guess);
copy.replace(copy.find(guess), 1, \"_\");
}
} else{
cout << \"That\'s wrong\" << endl;
wrong++;
}
  
cout << endl;
}
return 0;
}

Please write in visual studious for c++. Hangman Create a two-person version of Hangman (word-guessing game). The game begins with one player entering a secret
Please write in visual studious for c++. Hangman Create a two-person version of Hangman (word-guessing game). The game begins with one player entering a secret

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site