Nov 5, 2016 at 4:36am UTC
#include <iostream>
using namespace std;
void PlayWordBot();
string secretPhrase();
string VisiblePhrase(string Secret);
void Clearscreen();
string lettersPicked;
void PrintDisplay();
string input();
int failsRemaining;
int main()
{
PlayWordBot();
}
void PlayWordBot()
{
string secretphrase = secretPhrase();
string visiblePhrase = VisiblePhrase(secretphrase);
Clearscreen();
PrintDisplay();
}
string secretPhrase()
{
string myanswer;
cout << "Enter a word, phrase or a sentence: " << endl;
getline(cin, myanswer);
for (int i=0; i < myanswer.length(); i++)
{
tolower(myanswer[i]);
}
return myanswer;
}
string VisiblePhrase(string Secret)
{
for (int i=0; i < Secret.length(); i++ )
{
if(Secret[i] == ' ')
{
cout << ' ' ;
}
else if (ispunct(Secret[i]))
{
cout << Secret[i];
}
else
{
Secret[i] = '-';
cout << "_" ;
}
}
return Secret;
}
void Clearscreen()
{
for(int i =0; i < 50; i++)
{
cout << " " <<endl;
}
}
void PrintDisplay()
{
string myanswer;
string visiblePhrase;
string useranswer;
string lettersWrong;
int failsRemaining = 8;
cout << "=====================================" << endl;
cout << endl;
while (failsRemaining > 0 && visiblePhrase != secretPhrase)
{
if (secretPhrase[i] == myanswer[0])
{
change ++;
}
if (change == 0)
{
failsRemaining --;
lettersWrong += myanswer;
}
change = 0;
}
cout << "Guess remaining" << failsRemaining << endl;
cout << "Guess a letter" << endl;
char guessletter(string useranswer);
while (true);
if (guessletter.length() > 1)
{
cout << "Type one letter" << endl;
cin >> guessletter;
}
else if (isalpha(guessletter())
{
cout << "I meant letter." << endl;
}
}
Nov 5, 2016 at 8:46am UTC
What @Phone98 said, but I read through your code and er... For the most part it's very incomplete. All you've done is ask for help. I don't think anyone wants to write a hangman program for you. Perhaps you could be more specific in what you want us to help you with?