Skip to content

Instantly share code, notes, and snippets.

@realQuade
Created July 31, 2017 00:08
Show Gist options
  • Save realQuade/934365df06ad44653ad53e1eb6f11c63 to your computer and use it in GitHub Desktop.
Save realQuade/934365df06ad44653ad53e1eb6f11c63 to your computer and use it in GitHub Desktop.
Lesson 23 My Variant of Code
#include <iostream>
#include <string>
using namespace std;
//functions
void printIntro();
void playGame();
string getGuess();
string printGuess();
//variables
string Guess = "";
int main()
{
printIntro();
playGame();
return 0;
}
void printIntro() {
// introduce the game
constexpr int word_length = 8;
cout << "Welcome to Bulls and Cows, a fun word game.\n";
cout << "Can you guess the " << word_length << " letter isogram I'm thinking of?\n";
cout << endl;
}
void playGame() {
constexpr int number_of_turns = 5;
for (int count = 1; count <= number_of_turns; count++)
{
getGuess();
printGuess();
}
}
string getGuess() {
// get a guess from the player
cout << "Enter your guess: ";
getline(cin, Guess);
return Guess;
}
string printGuess() {
// repeat the guess back to them
cout << "Your guess was: " << Guess << endl;
cout << endl;
return Guess;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment