Question: The Main File The main file shall create a Game instance and utilize its methods to implement the game. Separating the logic that displays the

The Main File

The main file shall create a Game instance and utilize its methods to implement the game. Separating the logic that displays the menus to the player from the game of Numerical Wagers allows us to reuse the existing Numerical Wagers game in different programs or to change out our current view for a new one if we so choose. Additionally, the main class can be used to handle the number of questions in a game as well as allow a user to select the option to play again.

The Question Class

This class is responsible for storing the question and answer for a single question. In addition to a parameterized constructor, this class should have the following methods:

  • GetText ()
    • Returns an std::string that is the question body.
  • AnswerContainsDigit (char)
    • Returns a boolean (true or false) if the answer contains the character passed in.
    • This function is useful for knowing when to increment the number of incorrect guesses.
  • GetAnswerWithPlaceholders (std::vector)
    • Returns an std::string of the answer but digits in the answer that have not yet been guessed by the user should show an underscore.
      • For example, if a vector containing 1, 2, and 3 are passed in and the question's answer is 253, this function returns "2_3".
  • AllDigitsGuessed (std::string)
    • Returns true if no underscore is present in the input string, false otherwise.
    • A simple check that searching an input string for the underscore character.
    • Use this function on the response from GetAnswerWithPlaceholders.

In C++

C Question text: std::string answer: std::string Question() . Question(std::string, std::string) . GetText(): std::string AnswerContains Digit (char digit): bool . GetAnswerWith Placeholders(std::vector) : std::string . AllDigits Guessed (std::string): bool C Question text: std::string answer: std::string Question() . Question(std::string, std::string) . GetText(): std::string AnswerContains Digit (char digit): bool . GetAnswerWith Placeholders(std::vector) : std::string . AllDigits Guessed (std::string): bool

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!