Clarity is worth fighting for code

#include <iostream>
#include <string>

using namespace std;

void game_intro();
void play_game();
string get_guess();
void repeat_guess(string x);

int main() {
	game_intro();
	play_game();
	return 0;
}

void play_game() {
	int max_guesses = 5;
	for (int guesses_made = 0; guesses_made < max_guesses; guesses_made++) {
		string guess = get_guess();
		repeat_guess(guess);
	}
}

void game_intro() {
	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'm thinking of?" << endl;
	return;
}

string get_guess() {
	cout << endl << "Please enter your guess: ";
	string guess = "";
	getline(cin, guess);
	return guess;
}

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

Privacy & Terms