TheCOSCGameProject  1.0
Public Member Functions | List of all members
CodeGuesser Class Reference

Implements the CodeGuesser mini-game. More...

#include <minigames.h>

Inheritance diagram for CodeGuesser:
Inheritance graph
[legend]
Collaboration diagram for CodeGuesser:
Collaboration graph
[legend]

Public Member Functions

 CodeGuesser ()
 Constructor for the CodeGuesser game. More...
 
bool start () override
 Starts the CodeGuesser game. More...
 
bool addGuess ()
 Adds a guess to the list of guesses. More...
 
void printGuesses ()
 Prints all the player's guesses. More...
 
void printWords ()
 Prints all possible words. More...
 
int getWordLength () const
 Gets the length of the secret word. More...
 
int getGuessCount () const
 Gets the number of guesses made by the player. More...
 
std::string getLastGuess () const
 Gets the last guess made by the player. More...
 
std::string getGameName () override
 Gets the name of the game. More...
 
- Public Member Functions inherited from Game
virtual ~Game ()
 Virtual destructor for proper cleanup of derived classes. More...
 

Detailed Description

Implements the CodeGuesser mini-game.

The CodeGuesser class challenges the player to guess a secret code, which is a randomly selected word.

Constructor & Destructor Documentation

◆ CodeGuesser()

CodeGuesser::CodeGuesser ( )

Constructor for the CodeGuesser game.

Constructor for the CodeGuesser class.

Initializes the list of possible words and sets up the game.

Initializes the word list and randomly selects one word for the game.

Member Function Documentation

◆ addGuess()

bool CodeGuesser::addGuess ( )

Adds a guess to the list of guesses.

Add a guess and check it against the secret passcode.

Returns
True if the guess was added successfully, otherwise false.
True if the guess matches the passcode, false otherwise.

Colors the guess based on correctness (green for correct letters in the correct position, yellow for correct letters in the wrong position).

◆ getGameName()

std::string CodeGuesser::getGameName ( )
overridevirtual

Gets the name of the game.

CodeGuesser game.

Returns
A string representing the name of the game.

Get the name of the CodeGuesser game.

Returns
A string representing the name of the game.

Implements Game.

◆ getGuessCount()

int CodeGuesser::getGuessCount ( ) const

Gets the number of guesses made by the player.

Get the number of guesses made by the player.

Returns
The number of guesses made by the player.
The number of guesses as an integer.

◆ getLastGuess()

std::string CodeGuesser::getLastGuess ( ) const

Gets the last guess made by the player.

Get the last guess made by the player.

Returns
The last guess made by the player.
The last guess as a string.

◆ getWordLength()

int CodeGuesser::getWordLength ( ) const

Gets the length of the secret word.

Get the length of the word (always 5 in this game).

Returns
The length of the current secret word.
The length of the word (5).

◆ printGuesses()

void CodeGuesser::printGuesses ( )

Prints all the player's guesses.

Print all the guesses made by the player so far.

◆ printWords()

void CodeGuesser::printWords ( )

Prints all possible words.

Print all the possible words (for debugging or testing).

◆ start()

bool CodeGuesser::start ( )
overridevirtual

Starts the CodeGuesser game.

Start the CodeGuesser game.

Returns
True if the game was completed successfully, otherwise false.
True if the player successfully guesses the code, false otherwise.

The player has five attempts to guess a five-letter passcode.

Implements Game.


The documentation for this class was generated from the following files: