S02 updates

S02_L018 cin:

S02_L021 for loops:

Updated Fri Apr 21 2017 13:27

S02_L022 Clarity:

#include <iostream>
#include <string>

using namespace std;

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

int main()		// entry point
{
  PrintIntro();
  PlayGame();
  return 0;		// exit point
}

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

void PlayGame()		// loop for number of guesses
{
  constexpr int TRIES = 5;
  for (int i = 0; i < TRIES; i++)
  {
    string Guess = GetGuess();
    RepeatGuess(Guess);
    cout << endl;
  }
  return;
}

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

void RepeatGuess(string Guess)	// repeat guess to player
{
  cout << "You guessed '" << Guess << "'.\n";
  return;
}

Updated Fri Apr 21 2017 14:16

S02_L026 Classes:

Updated Fri Apr 21 2017 17:48

S02_L047 helper functions:

Updated Sun Apr 23 2017 11:32

S02_L048 ASCII art:


For those interested, I got the text from this site and the art from here
Updated Sun Apr 23 2017 16:25

Privacy & Terms