Skip to content

Instantly share code, notes, and snippets.

@Azada123
Created June 30, 2018 09:08
Show Gist options
  • Save Azada123/6597cb93aa33eed570379fe2cf761e33 to your computer and use it in GitHub Desktop.
Save Azada123/6597cb93aa33eed570379fe2cf761e33 to your computer and use it in GitHub Desktop.
// BullCowGame.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string>
void PrintIntro();
std::string GetGuessAndPrintItBack();
constexpr int WORD_LENGTH = 5;
int main()
{
PrintIntro();
std::cout << std::endl;
for (int count = 0; count < WORD_LENGTH; ++count)
{
GetGuessAndPrintItBack();
std::cout << std::endl;
}
return 0;
}
// Introduce the game
void PrintIntro()
{
std::cout << "Welcome to Bulls and Cows, A fun wordgame." << std::endl;
std::cout << "Can you guess the " << WORD_LENGTH << " letter isogram I´m thinking of?" << std::endl;
return;
}
// Get a guess from player and print it back
std::string GetGuessAndPrintItBack()
{
std::string Guess = "";
std::cout << "Enter your guess ? ";
std::getline(std::cin, Guess);
std::cout << "Your guess is " << Guess << std::endl;
return Guess;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment