#include
#include
using namespace std;
void printIntro();
void getGuessAndPrintIt();
int main() //entry point of the game
{
constexpr int MAX_TRIES = 5;
printIntro();
for (int count = 1; count <= MAX_TRIES; count++)
{
getGuessAndPrintIt();
}
return 0;
}
void printIntro() //print the intro text
{
constexpr int WORD_LENGTH = 9;
cout << “Welcome to Bulls & Cows, a freaking awesome game by Mornarion.\n”;
cout << “Try to guess the " << WORD_LENGTH;
cout << " letters isogram that I’m thinking… If you dare!!!\n\n”;
return;
}
void getGuessAndPrintIt() //get a guess from player
{
string Guess = “”;
cout << "What is your guess?: ";
getline(cin, Guess);
//return the guess to the playa
cout << "Your guess is: " << Guess << endl << endl;
return;
}
You may notice my getGuessAndPrintIt() is not of type string but void… I chose so because it’s not really returning anything (anything that is used by the program, anyway), so I intend to change it to string type once it’s necessary.
I am also using camelcase for methods and variables. Call me a rebel, if you will… XP