Created
August 28, 2017 18:04
-
-
Save anonymous/1d91178e9404b0405affae021a059dec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <string> | |
using namespace std; | |
//prototype for user-defined functions | |
void PrintIntro(); | |
void PlayGame(); | |
string GetGuess(); | |
string PrintGuess(); | |
string Guess = ""; | |
//entry point for our application | |
int main() | |
{ | |
PrintIntro(); | |
PlayGame(); | |
return 0; | |
} | |
// introduce the game to the user | |
void PrintIntro() { | |
constexpr int WORD_LENGTH = 5; | |
cout << "Welcome to Bulls and Cows!, a fun word-game! " << endl; | |
cout << "Can you guess the " << WORD_LENGTH << " letter isogram that I'm thinking of?" << endl; | |
cout << endl; | |
} | |
//Plays the loop of the game | |
void PlayGame() | |
{ | |
constexpr int GUESS_LIMIT = 5; | |
//loop for the number of turns asking guesses | |
for (int count = 0; count < GUESS_LIMIT; count++) { | |
GetGuess(); | |
PrintGuess(); | |
cout << endl; | |
} | |
} | |
// gets the guess and prints it back | |
string GetGuess() | |
{ | |
// get a guess from the user | |
cout << "Guess the isogram : "; | |
getline(cin, Guess); | |
return Guess; | |
} | |
//Prints the guess that the user entered | |
string PrintGuess() | |
{ | |
// repeat the guess back to them | |
cout << "Your guess was : " << Guess << endl; | |
return Guess; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment