I know that using namespace can cause problems later on so I started from the start just writing everything in long form
#include
#include
//using namespace std;
// User Functions
void PrintIntro();
void PlayGame();
std::string GetGuess();
void PrintBack(std::string);
int main()
{
PrintIntro();
PlayGame();
return 0;
}
void PrintIntro()
{
// Introduce the game
constexpr int WORD_LENGTH = 5;
std::cout << "Welcome to Bulls and Cows, a fun word game." << std::endl;
std::cout << std::endl;
std::cout << "Can you guess the " << WORD_LENGTH;
std::cout << " letter isogram I'm thinking of?" << std::endl;
std::cout << std::endl;
return;
}
std::string GetGuess()
{
// get a guess from the player
std::string Guess = ""; //defining Guess
std::getline(std::cin, Guess);
PrintBack(Guess);
return Guess;
}
void PlayGame()
{
//Loop for the number of turns allowed
constexpr int NUMBER_OF_TURNS = 5;
for (int count = 1; count <= NUMBER_OF_TURNS; count++)
{
GetGuess();
}
}
void PrintBack(std::string Guess)
{
//repeat the guess back
std::cout << "You guessed " << Guess << "!" << std::endl;
std::cout << std::endl;
return;
}