Question
Must be written in c++: Write a C++ program that will play a game of Word Guess as described below. Your class objects must follow
Must be written in c++:
Write a C++ program that will play a game of Word Guess as described below. Your class objects must follow the template below.
class Dictionary This class represents a container of words. The size of the container will not be known when an object of this type is instantiated.
State: container of words
Behavior: populates the container via the console, populates the container via a file, accesses a random word from the container
class Player This class represents a player of a game.
State: name of player, number of wins, number of losses
Behavior: typical tangible thing behavior
class GameState This class represents the state of a single game of word guess.
State: current word being played, current state of the users guessed word, letters incorrectly guessed, words incorrectly guessed, number of attempts left
Behavior: responsible for matching the user guess to the current word, responsible for accessing all state information
The Word Guess Game The following steps outline how this game should be played. Follow these directions carefully!
1. Populate the dictionary of words. A word may not contain a space. The dictionary can be populated by reading in words from the console or from a data file. The user must be allowed to choose how to populate the file. Both options must work and you may not limit the number of words (sentinel loop pattern!). The dictionary must be populated before the user is asked to play. You may assume valid data.
2. The user should be prompted whether to play the game or not (do not double prompt!). They should be allowed to replay without having to rerun your program (sentinel loop pattern!).
3. To play, a word must be randomly chosen from the dictionary of words. The word should be displayed to the user as a set of space delimited dashes where each dash represents a character in the word. The user will be allowed as many attempts as there are characters in the word. For example, if the word is hello the user should be allowed to guess at most 5 times. Notice max attempts is per character not per unique character. A user may guess a single letter or may attempt to guess the word. Each attempt counts as a guess, even if it is a repeat guess. The user wins the game if they guess the word or all the letters in the word before they have exhausted all attempts.
4. After each guess, display the current state of the guessed word (correctly guessed letters should be filled in), the number of remaining attempts, and a list of both letters and words previously guessed.
5. At the end of each game, let the user know if they won or lost and show the user the correct word (assuming they didn't correctly guess the word). After the user is finished playing, show the user their number of wins and losses.
6. You must use the three class objects above and you may not create any additional classes.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started