Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- void PrintIntro();
- void PlayGame();
- string GetGuess();
- bool PlayAgain();
- int main(int number)
- {
- PrintIntro();
- PlayGame();
- PlayAgain();
- return 0;
- }
- void PlayGame()
- {
- int Tries = 5;
- for (int count = 0; count < Tries; count++)
- {
- GetGuess();
- }
- }
- void PrintIntro()
- {
- constexpr int WordLength = 5;
- cout << "Welcome to Bulls and Cows!" << endl;
- cout << "Can you guess the word I'm thinking of?.. It's a ";
- cout << WordLength;
- cout << " letter word" << endl;
- return;
- }
- string GetGuess()
- {
- string Guess;
- cout << "Your guess: ";
- getline(cin, Guess);
- cout << "You guessed: ";
- cout << Guess << endl;
- cout << endl;
- return Guess;
- }
- bool PlayAgain()
- {
- cout << "Would you like to play again?";
- string Response = "";
- getline(cin, Response);
- cout << "First char: " << (Response[0] == 'y' || 'Y');
- cout << endl;
- return (Response[0] == 'y') || (Response[0] == 'Y');
- }
Advertisement
Add Comment
Please, Sign In to add comment