Skip to content

Instantly share code, notes, and snippets.

@wildBcat
Created June 19, 2018 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wildBcat/7494bcc154ca20e35274ac393021e908 to your computer and use it in GitHub Desktop.
Save wildBcat/7494bcc154ca20e35274ac393021e908 to your computer and use it in GitHub Desktop.
My code to separate the input and print
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
void PrintIntro();
string GetGuess();
void FiveTries();
void PrintGuess();
string Guess = "";
// The entry point for our applicaiton
int main()
{
PrintIntro();
FiveTries();
return 0;
}
// Introduce the game
void PrintIntro()
{
constexpr int WORD_LENGTH = 5;
cout << "Welcome to Bulls and Cows, a fun word game." << endl;
cout << "Can you guess the " << WORD_LENGTH << " letter isogram I am thinking of?" << endl;
cout << endl;
return;
}
// Limits the time the player can guess to 5
void FiveTries()
{
constexpr int GUESS_LENGTH = 5;
for (int i = 1; i <= GUESS_LENGTH; i++)
{
PrintGuess();
cout << endl;
}
return;
}
// Gets guess input from the player
string GetGuess()
{
cout << "Guess the word: ";
string Guess = "";
getline(cin, Guess);
return Guess;
}
// Prints the user's guess
void PrintGuess()
{
cout << "Your guess is: " << GetGuess() << endl;
return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment