I have added a parameter that can be adjusted once and it would update all areas that will reference it. see TotalGuesses():
#include
#include
using namespace std;
void PrintIntro();
void GuessLoop();
string GuessAndPrintBack();
// entry point for our application
int main()
{
PrintIntro();
GuessLoop();
TotalGuesses();
cout << endl;
return 0;
}
void PrintIntro()
{
// introduce the game
constexpr int WORD_LENGTH = 9;
cout << “Welcome to bulls and cows a fun word game\n”;
cout << "can you guess the “;
cout << WORD_LENGTH;
cout << " letter isogram I’m thignking of?\n”;
cout << endl;
return;
}
// Sets the total of guesses , use one place to adapt all.
int TotalGuesses()
{
return 5;
}
// this is for the loop function that allows x amout of guesses.
void GuessLoop()
{
for (int count = 1; count <= TotalGuesses(); count++)
{
GuessAndPrintBack();
}
}
// ask the player for his/her guess
string GuessAndPrintBack()
{
cout << "Tell me your guess? = "; string Guess = ""; getline(cin, Guess); cout << endl;
cout << "You have guessed = "; cout << Guess; cout << endl;
cout << endl;
// repeat the guess back to the palyer
return Guess;
}