My separated GetGuess and PrintBack functions

#include <iostream>
#include <string>

using namespace std;

void PrintIntro();
void PlayGame();
string GetGuess();
void PrintBack(string StringToPrint);



// the entry point for our application
int main()
{
	PrintIntro();
	PlayGame();
	return 0; // exit the application
}

void PlayGame()
{
	// loop for the number of turns asking for guesses
	constexpr int NUMBER_OF_TURNS = 5;
	for (int count = 0; count < NUMBER_OF_TURNS; count++)
	{
		PrintBack(GetGuess());
		cout << endl;
	}
}

// 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 am thinking of?\n";
	cout << endl;
	return;
}

// get a guess from the user
string GetGuess() 
{
	cout << "Enter your guess: ";
	string Guess = "";
	getline(cin, Guess);

	return Guess;
}

//print the guess back
void PrintBack(string StringToPrint)
{
	cout << "Your guess was: " << StringToPrint << endl;
	return;

}

Privacy & Terms