Skip to content

Instantly share code, notes, and snippets.

/main.cpp Secret

Created August 24, 2017 19:11
Show Gist options
  • Save anonymous/5dcc84708acc125bd7af3b20feb0c9c2 to your computer and use it in GitHub Desktop.
Save anonymous/5dcc84708acc125bd7af3b20feb0c9c2 to your computer and use it in GitHub Desktop.
lecture 23 challenge
#include <iostream>
#include <string>
using namespace std;
void printIntro();
void PlayGame();
string getGuess();
void PrintGuess(string &Guess);
int main()
{
printIntro();
PlayGame();
return 0;
}
void PlayGame()
{
constexpr int NUMBER_OF_TURNS = 5;
//loops for the amount of turns taking
for (int i = 0; i < NUMBER_OF_TURNS; i++)
{
getGuess();
cout << endl;
}
return;
}
//Introduce game
void printIntro()
{
constexpr int WORD_LENGTH = 5;
cout << "Welcome to the Bulls and Cows game. "
<< "A fun and challenging word game.\n"
<< "Guess the "
<< WORD_LENGTH
<< " letter isogram word.\n" << endl;
return;
}
//takes users guesses and shows them their guess
string getGuess()
{
string Guess = "";
cout << "What is your guess: ";
getline(cin, Guess);
PrintGuess(Guess);
return Guess;
}
void PrintGuess(string &Guess)
{
cout << "Your guess is: "
<< Guess << endl;
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment