Section 02 Lesson 20 Challenge Solution

#include <iostream>
#include <string>

void introGame();
void playGame();
std::string getGuess();
void printBack();

int main()
{
	introGame();
	playGame();
	return 0;
}

void playGame()
{
	//Looping through the number of tries
	constexpr int maxTries = 5;
	for (int input = 1; input <= maxTries; input++)
	{
		printBack();
		std::cout << std::endl;
	}
}

// Introduce the Bulls and Cows game
void introGame()
{
	constexpr int wordLength = 5;
	
	std::cout << "Welcome to Bulls and Cows, a fun guessing game." << std::endl;
	std::cout << "Please guess a " << wordLength;
	std::cout << " letter word that I am thinking of.\n";
	return;
}

// Get a guess from the player and print it back
std::string getGuess()
{
	std::cout << "Please enter your guess..." << std::endl;
	std::string sGuess = "";
	std::getline(std::cin, sGuess);
	return sGuess;
}

void printBack()
{
	std::cout << "Your guess was " << getGuess() << std::endl;
	return;
}