"Very Happy" fought hard for clarity

I worked and struggled and cried and tried, but I’m finally happy with the structure I created for my code.

#include <iostream>
#include <string>
#include <cwchar>
#include <Windows.h>



using namespace std; //doing this so I don't have to write std:: at the begining of every call
void PrintIntro(); //name of code for the intro (not in main, it's own thing, main is like a table of contents)
void PlayGame();
string GetGuess(); //Take the player's guess
string Guess = ""; //tells the program that the guess is open for the player to choose
string PrintGuess(); //This repeats the player's guess to them (prints back)
int limit = 5; //number of times you get to guess
int count = 0;
constexpr int WORD_LENGTH = 5; //number of letters in the word/isogram


int main()
{
	PrintIntro(); // This forces the intro to display first
	PlayGame(); //Play the game
	return 0;
}



void PrintIntro()
{
	// INTRODUCTION; How to play the game
	// I want to make the font red because I like to stand out
	HANDLE outcon = GetStdHandle(STD_OUTPUT_HANDLE);//you don't have to call this function every time

	CONSOLE_FONT_INFOEX font;//CONSOLE_FONT_INFOEX is defined in some windows header
	GetCurrentConsoleFontEx(outcon, false, &font);//PCONSOLE_FONT_INFOEX is the same as CONSOLE_FONT_INFOEX*
	font.dwFontSize.X = 7;
	font.dwFontSize.Y = 12;
	SetCurrentConsoleFontEx(outcon, false, &font);

	// Carry on with the relevant code
	SetConsoleTextAttribute(outcon, 0x0C);
	cout << "__________      .__  .__                              .___ _________                      \n";
	cout << "\\______   \\__ __|  | |  |   ______ _____    ____    __| _/ \\_   ___ \\  ______  _  ________\n";
	cout << " |    |  _/  |  \\  | |  |  /  ___/ \\__  \\  /    \\  / __ |  /    \\  \\/ /  _ \\ \\/ \\/ /  ___/\n";
	cout << " |    |   \\  |  /  |_|  |__\\___ \\   / __ \\|   |  \\/ /_/ |  \\     \\___(  <_> )     /\\___ \\ \n";
	cout << " |______  /____/|____/____/____  > (____  /___|  /\\____ |   \\______  /\\____/ \\/\\_//____  >\n";
	cout << "        \\/                     \\/       \\/     \\/      \\/          \\/                  \\/ \n";	cout << "Welcome to Bulls and Cows!\n";
	cout << "A fun word game, where you try to guess a " << WORD_LENGTH << " letter word without repeating letters(called an isogram).\n\n";
	cout << "RULES:\n";
	cout << "a) You will have " << limit << " guesses\n";
	cout << "b) If you have a 'bull' then you have the correct letter in the correct place\n";
	cout << "c) If you have a cow, you have the correct letter, but in the wrong place\n\n";
	cout << "Can you guess the " << WORD_LENGTH << " letter isogram I'm thinking of?\n\n";

	return;
}



void PlayGame()
{
	for (int count = 0; count < limit; count++) 
	{
		GetGuess();
		cout << endl;
		PrintGuess();
		cout << endl;
	}
	return;
}



string GetGuess() //Main string for asking the player for a guess
{
	// USER INPUT; get a guess from the player
	cout << "\nEnter your guess; ";
	Guess = "";
	getline(cin, Guess);
	return Guess;
}



//repeat the guess to the player (print guess)
string PrintGuess()
{
	// COMFIRMATION; repeat guess back to the player
	cout << "Your guess was: " << Guess << endl;
	return Guess;
}

And it looks like this in the console;

Privacy & Terms