Skip to content

Instantly share code, notes, and snippets.

@Ryuketsukami
Created April 8, 2017 02:20
Show Gist options
  • Save Ryuketsukami/ec5bac62f600ecc9f8630292d455194b to your computer and use it in GitHub Desktop.
Save Ryuketsukami/ec5bac62f600ecc9f8630292d455194b to your computer and use it in GitHub Desktop.
#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