Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <string>
- #include "FBullCowGame.h"
- using int32 = int;
- using FText = std::string;
- void PrintIntro();
- void PlayGame();
- bool AskToPlayAgain();
- FText GetGuess();
- FBullCowGame BCGame;
- int main ()
- {
- bool bPlayAgain = false;
- do
- {
- PrintIntro();
- PlayGame();
- bPlayAgain = AskToPlayAgain();
- } while (bPlayAgain == true);
- system("Pause");
- return 0;
- }
- void PrintIntro()
- {
- //introduces the game
- std::cout << "Welcome to Bulls and Cow, a fun word game" << std::endl;
- std::cout << "Can you guess the " << BCGame.GetHiddenWordLength();
- std::cout << " letter isogram I'm thinking off?" << std::endl;
- return;
- }
- void PlayGame()
- {
- BCGame.Reset();
- int32 MaxTries = BCGame.GetMaxTries();
- std::cout << "You have " << MaxTries << " max tries."<< std::endl;
- for (int32 count = 1; count <= MaxTries; count++)
- {
- FText Guess = GetGuess();
- FBullCowCount BullCowCount = BCGame.SubmitGuess(Guess);
- std::cout << "Bulls = " << BullCowCount.Bulls << "." << std::endl;
- std::cout << "Cows = " << BullCowCount.Cows << "." << std::endl;
- }
- }
- FText GetGuess()
- {
- //get the guess from the player
- int32 CurrentTry = BCGame.GetCurrentTries();
- std::cout << "Try " << CurrentTry << "." << std::endl;
- FText Guess = "";
- std::cout << "Enter your guess: ";
- std::getline(std::cin, Guess);
- return Guess;
- }
- bool AskToPlayAgain()
- {
- bool status = false;
- std::cout << "Do you want to play again?(y/n)" << std::endl;
- FText response = "";
- std::getline(std::cin, response);
- if (response [0] == 'y' || response [0] == 'Y')
- {
- status = true;
- }
- return status;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement