FBullCowGame Class Definition


First, have to admit some confusion here as “how far” to take this class definition. Usually, at least from my experience with objects, an object is purely self-encapsulated, meaning it does its own thing with only necessary input from outside the class to energize it. With the little bit in the video, I was left a bit bewildered as to Public/Private direction - I had thought from the dialog the game class should be fully abstracted so it could be inserted anywhere in some “code,” (e.g., mini-game like), but, it seems from the instruction there’s some public interaction that may make this more a “psuedo class.”

Well, anyway, I shall see as I go I suppose…

But, per request, here’s my stab at creating an FBullCowGame class definition:

[CODE]#pragma once


using namespace std;

class FBullCowGame {
void Reset(); // TODO make a more rich return value
void SetWordLength(int WordLength);
void SetMaxTries(int MaxTries);
void DoGame();

int CurrentTry;
int MaxTries;
int WordLength;
string CurrentWord;
int NumBulls;
int NumCows;
bool GameWon;
string GetAsciiArt();
void DisplayWelcome();
bool AskToPlay();
void SetTheWord();
void SetCurrentTry(int CurrentTry);
int GetCurrentTry();
int GetMaxTries();
void SetCurrentGuess(string PlayerGuess);
bool CheckGuess(string PlayerGuess); // How is the player doing? Bulls/Cows/Win/Quit…
int GetBulls(string PlayerGuess);
int GetCows(string PlayerGuess);
bool CheckWin(); // compare bulls to word length, if equal, a win
bool PlayAgain();
bool CheckQuit(string PlayerGuess); // PlayerGuess could be “Q” to quit
bool ConfirmQuit();
void DisplayProgress(); // outputs bulls/cows, etc., to screen
bool IsIsoGram(string TheWord);




Privacy & Terms