Code by Kevin (Answer to the task)

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

using namespace std;

void PrintIntro();
string GetGuess();

int main()
{
    PrintIntro();

    string Guess = GetGuess();

    return 0;
}

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);
    // repeat the guess back to them
    cout << "Your guess was: " << Guess << endl;

    // get a guess from the player
    cout << "Enter your guess: ";
    getline(cin, Guess);
    // repeat the guess back to them
    cout << "Your guess was: " << Guess << endl;

    cout << endl;

    return Guess;
};

Privacy & Terms