#include <iostream>
#include <string>
using namespace std;
void PrintIntro();
void PlayGame();
string GetGuess();
void RepeatGuess(string Guess);
// app entry point
int main() {
// game intro
PrintIntro();
PlayGame();
cout << endl;
return 0;
}
// prints intro to the game
void PrintIntro() {
constexpr int WORD_LENGTH = 6;
cout << "Welcome to Bulls and Cows." << endl;
cout << "Can you guess the " << WORD_LENGTH << " isogram I'm thinking of?" << endl;
return;
}
void PlayGame() {
string Guess = "";
constexpr int NUMBER_OF_GUESSES = 5;
for (int i = 0; i < NUMBER_OF_GUESSES; ++i) {
// get user input
Guess = GetGuess();
// repeat user guess
RepeatGuess(Guess);
}
return;
}
// gets guess input from the user
string GetGuess() {
string Input = "";
// get user input
cout << endl << "Your guess: ";
getline(cin, Input);
return Input;
}
void RepeatGuess(string Guess) {
cout << "Your guess was: " << Guess << "." << endl;
return;
}
1 Like
Awesome code!