Code by Kevin (Answer to task in lecture 26)

Hello dear @ben and Community,

#include "pch.h"
#include <iostream>
#include <string>

using namespace std;

void PrintIntro();
void PlayGame();
string GetGuess();
void PrintGuess(string);

int main() {
	PrintIntro();

	PlayGame();

	return 0;
}

void PlayGame()
{
	constexpr int NUMBER_OF_TURNS = 5;

	for (size_t i = 0; i < NUMBER_OF_TURNS; i++) {
		cout << "(" << i + 1 << "): ";
		PrintGuess(GetGuess());
	}
}

void PrintIntro() {
	// introduce the game
	constexpr int WORLD_LENGTH = 9;
	cout << "Welcome to Bulls and Cows, a fun word game.\n";
	cout << "Can you guess the " << WORLD_LENGTH;
	cout << " letter isogram I'm thinking of?\n";
	cout << endl;
	return;
}

string GetGuess() {
	// get a guess from the player
	cout << "Enter your guess: ";
	string Guess = "";
	getline(cin, Guess);


	return Guess;
};

void PrintGuess(string InputString) {
	cout << "Your guess was: " << InputString << endl;
	return;
}

Kind regards
Kevin

Hi, what exactly pch.h is for??

1 Like

Hello @Angel_Ramirez,

I don’t know. It’s standard in Visual Studio 2017.

Cheers
Kevin

I also don’t have pch.h and I’m using VS2017 as well. You haunted, bruh.

1 Like

https://solarbotics.com/product/41060/

Then, you have a really old PC.

It’s a 2015 Acer Predator, so ancient by tech standards, lol. I’m surprised the age of a computer affects the IDE in any situation. I always assumed they needed to be downright identical for courses like this to work. shrug

1 Like

Privacy & Terms