#include "GameCase.h" /* Private */ void GameCase::copyFrom(const GameCase& other) { this->command = other.command; this->description = new char[strlen(other.description) + 1]; strcpy(this->description, other.description); this->func = other.func; } void GameCase::free() { delete[] description; } /* Public */ GameCase::GameCase() : GameCase('\0', nullptr, nullptr) {} GameCase::GameCase(char command, const char* description, bool func(double&)) { this->command = command; this->func = func; if (description == nullptr) return; int descLen = strlen(description); this->description = new char[descLen + 1]; strcpy(this->description, description); } GameCase::GameCase(const GameCase& other) { this->copyFrom(other); } GameCase& GameCase::operator=(const GameCase& other) { if (this != &other) { this->free(); this->copyFrom(other); } return *this; } GameCase::~GameCase() { this->free(); } char GameCase::get_comm() const { return this->command; } void GameCase::print() const { std::cout << this->command << " - " << this->description << std::endl; } bool GameCase::exec(double& bet) const { return this->func(bet); }