Exemplo n.º 1
0
//play the game
void PlayGame()
{
	BCGame.Reset();
	int32 MaxTries = BCGame.GetMaxTries();
	
	//loop asking for guess while
	//game is NOT won and their are still tries remainging
	while(!BCGame.IsGameWon() && BCGame.GetCurrentTry() <= MaxTries)
	{
		FText Guess = GetValidGuess();
		

		//submit a valid guess to game
		FBullCowCount BullCowCount = BCGame.SubmitGuess(Guess);
		std::cout << "Bull = " << BullCowCount.Bulls;
		std::cout << ". Cows = " << BullCowCount.Cows;

		std::cout << std::endl;
	}

	PrintGameSummary();

	

	return;
}
Exemplo n.º 2
0
// Plays a single game to completion
void PlayGame()
{
	BCGame.Reset();
	int32 MaxTries = BCGame.GetMaxTries();
	//Loop asking for guesses while the game is NOT won and there are still turns
	while (!BCGame.IsGameWon() && BCGame.GetCurrentTry() <= MaxTries) 
	{
		FText Guess = GetValidGuess(); 
		FBullCowCount BullCowCount = BCGame.SubmitValidGuess(Guess);
		std::cout << "Bulls = " << BullCowCount.Bulls;
		std::cout << ", Cows = " << BullCowCount.Cows << "\n\n";
	}
	PrintGameSummary();
}
Exemplo n.º 3
0
int main(int32 argc, const char * argv[]) {

    // Do - While loop
    bool bPlayAgain = false;
    do
    {
        BCGame.Reset();
        PrintIntro(); // form of abstraction
        PlayGame();
        bPlayAgain = AskToPlayAgain();
    } while(bPlayAgain);
    return 0;
    //TODO: Hello world
}
Exemplo n.º 4
0
// plays a single game to completion
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);
		PrintGuess(BullCowCount);
	}

	return;
}
Exemplo n.º 5
0
// plays a single game to completion
void PlayGame()
{
	BCGame.Reset();
	int32 MaxTries = BCGame.GetMaxTries();


	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;
}
Exemplo n.º 6
0
// plays a single game to completion
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;
}
Exemplo n.º 7
0
void PlayGame()
{
    BCGame.Reset();
    int MaxTries = BCGame.GetMaxTries();
    
    //loop asking for guesses while the game is NOT won
    while (!BCGame.IsGameWon() && BCGame.GetCurrentTry() <= MaxTries)
    {
        FText Guess = GetGuess();        //submit valid guess to game
        FBullCowCount BullCowCount = BCGame.SubmitValidGuess(Guess);
        
        //print number of bulls and cows
        std::cout << "Bulls = " << BullCowCount.Bulls;
        std::cout << " Cows = " << BullCowCount.Cows << "\n\n";
        
        std::cout << "Your guess was: " << Guess << std::endl;
        std::cout << std::endl;
    }
    PrintGameSummary();
    return;
}
Exemplo n.º 8
0
void PlayGame(){
    BCGame.Reset();
    
    PrintIntro();
    
    // Loop for the number of turns asking for guesses
    for (int32 count = 1; count <= BCGame.GetMaxTries(); count++) {
        FText guess = GetGuess();
        
        EWordStatus status = BCGame.CheckGuessValidity(guess);
        
        switch (status) {
            case EWordStatus::OK: {
                FBullCowCount bullCowCount = BCGame.SubmitGuess(guess);
                // print the number of bulls and cows
                std::cout << "Bulls " << bullCowCount.Bulls;
                std::cout << " Cows " << bullCowCount.Cows;
                std::cout << std::endl;

                break;
            }
            case EWordStatus::Wrong_Length: {
                std::cout << "Wrong length! Try again.\n";
                break;
            }
            case EWordStatus::Not_Lowercase : {
                std::cout << "Not Lowercase! Try again.\n";
                break;
            }
            default: {
                std::cout << "Not Valid! Try again.\n";
                break;
            }
        }
        if (status == EWordStatus::OK) {
        }
    }
    return;
}
Exemplo n.º 9
0
void PlayGame()
{
	BCGame.Reset();
	int32 MaxTries = BCGame.GetMaxTries();
	

	//Loop for the number of turns asking for guesses
	//TODO change from for to while loop
	for (int32 count = 0; count < MaxTries; count++)
	{
		
		FText Guess = GetGuess(); //TODO make loop checking valid

		//Submit valid guess to the game
		FBullCowCount BullCowCount = BCGame.SubmitGuess(Guess);
		//Print number of bulls and cows
		std::cout << "Bulls = " << BullCowCount.Bulls;
		std::cout << "Cows = " << BullCowCount.Cows;

		std::cout << std::endl;
	}

	//TODO summarise game
}