So, this is what I ended up with.
I selected to make a PrintGuess()-function to print the guess also. Donโt know if needed or not, but now I have it.
And I LOVE my Bulls and Cow ASCII-art!!
#include
#include
using namespace std;
// Function prototypes
void PrintIntro();
void PlayGame();
string GetGuess();
void PrintGuess(string);
// the entry point for our application
int main()
{
PrintIntro();
PlayGame();
cout << endl;
return 0;
}
// Introduce the game
void PrintIntro()
{
constexpr int WORD_LENGTH = 5;
cout << "Welcome to Bulls and Cows, a fun word game." << endl;
cout << endl;
cout << " , ,\t\t|\t /) (\\\n";
cout << " / \\\t|\t.-._((,~~.))_.-,\n";
cout << "((__-^^-,-^^-__))\t|\t `-. @@ ,-'\n";
cout << " `-_---' `---_-'\t|\t / ,o--o. \\\n";
cout << " <__|o` 'o|__>\t\t|\t ( ( .__. ) )\n";
cout << " \\ ` /\t\t|\t ) `----' (\n";
cout << " ): :(\t\t|\t / \\\n";
cout << " :o_o:\t\t|\t / \\\n";
cout << " \"-\"\t\t|\t/ \\\n";
cout << endl;
cout << "Can you guess the " << WORD_LENGTH << " letter isogram I'm thinking of?" << endl;
return;
}
void PlayGame()
{
// loop for the number of turns asking for guesses
constexpr int NUMBER_OF_TURNS = 5;
for (int count = 1; count <= NUMBER_OF_TURNS; count++)
{
PrintGuess(GetGuess());
}
return;
}
// Get a guess from the player
string GetGuess()
{
string Guess = โโ;
cout << "\nPlease enter your guess: ";
getline(cin, Guess);
return Guess;
}
void PrintGuess(string Guess)
{
cout << "Your guess was " << Guess << endl;
return;
}