#include <iostream>
#include <string>
using namespace std;
void PrintIntro();
string GetGuessAndPrintBack();
//entry point for our application
int main()
{
PrintIntro();
int count = 0;
for (int count = 1; count <= 5; count++)
{
GetGuessAndPrintBack();
cout << endl;
}
cout << endl;
return 0;
}
// introduce the game
void PrintIntro()
{
constexpr int WORD_LENGTH = 5;
cout << "Welcome to Bulls and Cows, a fun word game.\n";
cout << "Can you guess the " << WORD_LENGTH;
cout << " letter isogram I'm thinking of?\n";
return;
}
// get a guess from the player
string GetGuessAndPrintBack()
{
cout << "Your Guess: ";
string Guess = "";
getline(cin, Guess);
// repeat the guess back to them
cout << "Your Guess is " << Guess << ".\n";
return Guess;
}
Magic numbers strike again!
fix…
#include <iostream>
#include <string>
using namespace std;
void PrintIntro();
string GetGuessAndPrintBack();
//entry point for our application
int main()
{
PrintIntro();
int limit = 5;
for (int count = 1; count <= limit; count++)
{
GetGuessAndPrintBack();
cout << endl;
}
cout << endl;
return 0;
}
// introduce the game
void PrintIntro()
{
constexpr int WORD_LENGTH = 5;
cout << "Welcome to Bulls and Cows, a fun word game.\n";
cout << "Can you guess the " << WORD_LENGTH;
cout << " letter isogram I'm thinking of?\n";
return;
}
// get a guess from the player
string GetGuessAndPrintBack()
{
cout << "Your Guess: ";
string Guess = "";
getline(cin, Guess);
// repeat the guess back to them
cout << "Your Guess is " << Guess << ".\n";
return Guess;
}