Skip to content

Instantly share code, notes, and snippets.

@Vraelir
Created October 13, 2017 14:19
Show Gist options
  • Save Vraelir/83ca90366bcc2b33e736d1702a5ffe0b to your computer and use it in GitHub Desktop.
Save Vraelir/83ca90366bcc2b33e736d1702a5ffe0b to your computer and use it in GitHub Desktop.
Bulls and Cows GetGuess Challenge
#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