Created
October 13, 2017 14:19
-
-
Save Vraelir/83ca90366bcc2b33e736d1702a5ffe0b to your computer and use it in GitHub Desktop.
Bulls and Cows GetGuess Challenge
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; | |
// Methods | |
void PrintIntro(); | |
string GetGuess(); | |
void PrintGuess(string Guess); | |
//Variables | |
string Guess = ""; | |
// The entry point for the application | |
int main() { | |
PrintIntro(); | |
GetGuess(); | |
//PrintGuess(Guess); //Called directly from GetGuess | |
GetGuess(); | |
//PrintGuess(Guess); //Called directly from GetGuess | |
return 0; | |
} | |
void PrintIntro() { | |
// Introduce the game | |
constexpr int WORD_LENGTH = 9; | |
cout << "Welcome to Bulls and Cows, a fun word game" << endl; | |
cout << "Can you guess the " << WORD_LENGTH << " letter isogram I'm thinking of?" << endl; | |
cout << endl; | |
return; | |
} | |
string GetGuess() { | |
// Get a guess from the player | |
cout << "Enter your guess here: "; | |
getline(cin, Guess); | |
PrintGuess(Guess); | |
return Guess; | |
} | |
void PrintGuess(string StoredGuess) { | |
// Repeat the guess back to the player | |
cout << "Your guess: " << StoredGuess << endl; | |
cout << endl; | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment