Does it matter where I call PrintGameSummary()?

Does it matter where I put “PrintGameSummary()”, Ben asks for it to be put at the end of PlayGame, but my initial instinct was to put it in “Main()” after “PlayGame();”

I pasted code showing it in BOTH places, which I know would duplicate it, I was just wondering WHY Ben did the one and not the other. When I tested it in my initial spot it seemed like it worked perfectly.

int main()
{
	std::cout << BCGame.GetCurrentTry();

	bool bPlayAgain = false;
	do {
		PrintIntro();
		PlayGame();
		**PrintGameSummary();**
		bPlayAgain = AskToPlayAgain();
	} while (bPlayAgain);
		
	return 0;
}

void PlayGame()
{
	BCGame.Reset();
	int32 MaxTries = BCGame.GetMaxTries();

	// loop asking for guesses while the game is NOT won and there are still tries remaining
	while (!BCGame.IsGameWon() && BCGame.GetCurrentTry() <= MaxTries) {	
		FText Guess = GetValidGuess();

		// Submit Valid Guess to the game, and receive counts
		FBullCowCount BullCowCount = BCGame.SubmitValidGuess(Guess);
		std::cout << "Bulls = " << BullCowCount.Bulls;
		std::cout << ". Cows = " << BullCowCount.Cows << "\n\n";
	}

	**PrintGameSummary();**
	return;
}

Hello dear @gordoncaister,

just remember the forward-declaration earlier in this course. Use it and you are fine :slight_smile:

Cheers
Kevin

Privacy & Terms