Created
June 19, 2018 03:08
-
-
Save wildBcat/7494bcc154ca20e35274ac393021e908 to your computer and use it in GitHub Desktop.
My code to separate the input and print
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 "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