TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Functions for the Memory Game implementation. More...
Functions | |
template<typename T > | |
bool | is_number (const T &input) |
Utility function to verify if the given input is a number or not. This is very useful to prevent the program being stuck in a loop. | |
template<typename T > | |
void | init (std::vector< T > *table) |
Initializes the table with the letters. | |
template<typename T > | |
void | print_table (const std::vector< T > &table) |
Utility function to print the table. | |
template<typename T > | |
void | reset_data (const std::vector< T > &table, int *answer, int *old_answer, int *memory_count) |
Utility function that resets the data if the user enters an invalid value. | |
template<typename T > | |
void | ask_data (const std::vector< T > &table, int *answer, int *old_answer, int *memory_count) |
Function that asks the user for their input in the table they previously chose. | |
template<typename T > | |
bool | match (const std::vector< T > &table, std::vector< T > *table_empty, const int &answer, bool *first_time, int *old_answer, int *memory_count) |
Checks if the two values given by the user match. | |
template<typename T > | |
void | assign_results (std::vector< T > *table_empty, std::vector< T > *table, int *answer, bool *first_time, int *old_answer, int *memory_count) |
Function to assign the results to the table. | |
Functions for the Memory Game implementation.
void games::memory_game::ask_data | ( | const std::vector< T > & | table, |
int * | answer, | ||
int * | old_answer, | ||
int * | memory_count ) |
Function that asks the user for their input in the table they previously chose.
T | The type of the table. |
table | The table that's used to get the user's input and data. |
answer | The user's answer. |
old_answer | The user's previous answer. |
memory_count | A counter to check if the user has already answered two values. |
Definition at line 161 of file memory_game.cpp.
void games::memory_game::assign_results | ( | std::vector< T > * | table_empty, |
std::vector< T > * | table, | ||
int * | answer, | ||
bool * | first_time, | ||
int * | old_answer, | ||
int * | memory_count ) |
Function to assign the results to the table.
Also checkes if the user has answered all the values already, as well as verify if the user made a match or not.
T | The type of the tables. |
table_empty | The table with no values, slowly assigned from table depending on the user's input. |
table | The table with the original values. |
answer | The user's answer. |
first_time | A boolean to check if the user has already answered a value. |
old_answer | The user's previous answer. |
memory_count | A counter to check if the user has already answered two values. |
Definition at line 289 of file memory_game.cpp.
void games::memory_game::init | ( | std::vector< T > * | table | ) |
Initializes the table with the letters.
T | The type of the table. |
table | The table to initialize. |
Definition at line 80 of file memory_game.cpp.
bool games::memory_game::is_number | ( | const T & | input | ) |
Utility function to verify if the given input is a number or not. This is very useful to prevent the program being stuck in a loop.
T | The type of the input |
input | The input to check. |
Definition at line 62 of file memory_game.cpp.
bool games::memory_game::match | ( | const std::vector< T > & | table, |
std::vector< T > * | table_empty, | ||
const int & | answer, | ||
bool * | first_time, | ||
int * | old_answer, | ||
int * | memory_count ) |
Checks if the two values given by the user match.
T | The type of the table. |
table_empty | The table with no values, slowly assigned from table depending on the user's input. |
table | The table with the original values. |
answer | The user's answer. |
first_time | A boolean to check if the user has already answered a value. |
old_answer | The user's previous answer. |
memory_count | A counter to check if the user has already answered two values. |
Definition at line 235 of file memory_game.cpp.
void games::memory_game::print_table | ( | const std::vector< T > & | table | ) |
Utility function to print the table.
T | The type of the table. |
table | The table to print. |
Definition at line 123 of file memory_game.cpp.
void games::memory_game::reset_data | ( | const std::vector< T > & | table, |
int * | answer, | ||
int * | old_answer, | ||
int * | memory_count ) |
Utility function that resets the data if the user enters an invalid value.
T | The type of the table. |
table | The table that will be used to call ask_data() . |
answer | The user's answer. |
old_answer | The user's previous answer. |
memory_count | A counter to check if the user has already answered two values. |
Definition at line 211 of file memory_game.cpp.