Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include "FBullCowGame.h"
- using FText = std::string;
- void PrintIntro();
- void PlayGame();
- FText Guess;
- FText GetGuess();
- bool AskToPlayAgain(); //also puts a bool to the console for later use
- FBullCowGame BCGame;
- int main()
- {
- bool bPlayAgain = false;
- do {
- PrintIntro();
- PlayGame();
- bPlayAgain = AskToPlayAgain();
- }
- while (bPlayAgain);
- return 0; //exit the program
- }
- void PlayGame()
- {
- int MyCurrentTry = BCGame.GetCurrentTry();
- int MaxTries = BCGame.GetMaxTries();
- std::cout << MaxTries << std::endl;
- constexpr int Number_Of_Turns = 5;
- //TODO change from FOR to WHILE loop when we are validating guesses
- for (int count = 1; count <= MaxTries; count++)
- {
- std::cout << "This will be guess #" << MyCurrentTry << std::endl;
- FText Guess = GetGuess(); //TODO make loop to check guess validity
- //submit valid guess to the game
- //pring number of bulls and cows
- std::cout << "Your guess was: " << Guess << std::endl;
- std::cout << std::endl;
- MyCurrentTry++;
- //TODO add a game summary
- //Print out the number of remaining guesses
- }
- }
- //get a guess from the user
- FText GetGuess()
- {
- std::cout << "Please enter your guess: ";
- FText Guess = "";
- getline(std::cin, Guess);
- return Guess;
- }
- bool AskToPlayAgain()
- {
- std::cout << "Do you want to play again? (y/n)? ";
- FText Response = "";
- getline(std::cin, Response);
- return (Response[0] == 'y') || (Response[0] == 'Y');
- }
- //introduce the game
- void PrintIntro()
- {
- constexpr int WORD_LENGTH = 5;
- std::cout << "Welcome to Bulls and Cows, a word game!\n";
- std::cout << "Can you guess the ";
- std::cout << WORD_LENGTH;
- std::cout << " letter isogram I'm thinking of?\n";
- std::cout << std::endl;
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement