Created
April 8, 2017 02:20
-
-
Save Ryuketsukami/ec5bac62f600ecc9f8630292d455194b to your computer and use it in GitHub Desktop.
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; | |
void PrintIntro() { | |
// introduction to the game | |
constexpr int WORD_LENGTH = 9; | |
cout << "Greetings Warrior.\nDo you think that you are smart enough to overcome my trial and guess the "; | |
cout << WORD_LENGTH; | |
cout << " letter isogram that I'm thinking of?\n"; | |
cout << endl; | |
return; | |
} | |
string GetGuess(){ | |
// get a guess from the player | |
cout << "Enter your guess: "; | |
string Guess = ""; | |
getline(cin, Guess); | |
return Guess; | |
} | |
void PlayGame() | |
{ | |
constexpr int limit = 5; | |
for (int count = 1; count <= limit; count++) | |
{ | |
string Guess = GetGuess(); | |
cout << "your guess was: " << Guess << endl; | |
} | |
return; | |
} | |
bool Ask() | |
{ | |
cout << "Would you like to play again?(y/n) "; | |
string Response = ""; | |
getline(cin, Response); | |
return (Response[0] == 'y') || (Response[0] == 'Y'); | |
} | |
int main() | |
{ | |
PrintIntro(); | |
do | |
{ | |
PlayGame(); | |
} while (Ask() > 0); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment