isGameWon() with references

bool FBullCowGame::isGameWon(const int32 & bulls, const int32 & length)const
{
    return bulls == length;
}

in my functions.h

void const playGame(FBullCowGame & Game)
{
    int32 maxTries = Game.getMaxTries();
    int32 currentTry = Game.getCurrentTry();
    FText guess;
    FBullCowCount bullCowCount;
    int32 bulls = 0;
    int32 length = Game.getMaxLength();
    bool isGameWon = false;
    //loop through number of turns asking for a guess
    while (!isGameWon && currentTry <= maxTries)
    {
	guess = "";
	std::cout << "Current Try: " << currentTry << std::endl;
	do
	{
		guess = getGuess(guess);
	} while (Game.checkGuessValidity(guess) != EGuessStatus::OK);

	bullCowCount = Game.submitGuess(guess);
	std::cout << "Bulls: " << bullCowCount.Bulls << std::endl;
	std::cout << "Cows: " << bullCowCount.Cows << std::endl;
	bulls = bullCowCount.Bulls;
	printGuess(guess);
	Game.incrementTurnNumber();
	currentTry = Game.getCurrentTry();
	isGameWon = Game.isGameWon(bulls, length);
    }

//i plan to fix this up soon
    if (bulls == Game.getMaxLength())
    {
	std::cout << "Congratulations, you have won!" << std::endl;
    }
    else
    {
	std::cout << "Game Over, you could not guess correctly!\n Please Play Again!" << std::endl;
    }
}

Privacy & Terms