Skip to content

Instantly share code, notes, and snippets.

Created August 28, 2017 18:04
Show Gist options
  • Save anonymous/1d91178e9404b0405affae021a059dec to your computer and use it in GitHub Desktop.
Save anonymous/1d91178e9404b0405affae021a059dec to your computer and use it in GitHub Desktop.
#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