Created
July 31, 2017 00:08
-
-
Save realQuade/934365df06ad44653ad53e1eb6f11c63 to your computer and use it in GitHub Desktop.
Lesson 23 My Variant of Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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