/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Harl.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: fgras-ca +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2023/12/27 15:12:29 by fgras-ca #+# #+# */ /* Updated: 2023/12/27 16:35:25 by fgras-ca ### ########.fr */ /* */ /* ************************************************************************** */ #include "Harl.hpp" Harl::Harl() {} void Harl::debug(void) { std::cout << "[DEBUG]\nI love having extra bacon for my 7XL-double-cheese-triple-pickle-specialketchup burger.\nI really do!" << std::endl; } void Harl::info(void) { std::cout << "[INFO]\n I cannot believe adding extra bacon costs more money.\nYou didn’t put enough bacon in my burger! If you did, I wouldn’t be asking for more!" << std::endl; } void Harl::warning(void) { std::cout << "[WARNING]\n I think I deserve to have some extra bacon for free.\nI’ve been coming for years whereas you started working here since last month." << std::endl; } void Harl::error(void) { std::cout << "[ERROR]\nThis is unacceptable! I want to speak to the manager now." << std::endl; } void Harl::complain(std::string level) { void (Harl::*complaints[])(void) = {&Harl::debug, &Harl::info, &Harl::warning, &Harl::error}; std::string levels[4] = {"DEBUG", "INFO", "WARNING", "ERROR"}; int i = 0; while (levels[i] != level and i < 4) i++; switch (i) { case 0: (this->*complaints[0])(); case 1: (this->*complaints[1])(); case 2: (this->*complaints[2])(); case 3: { (this->*complaints[3])(); break; } default: std::cout << "[ Probably complaining about insignifiant problems ]" << std::endl; break; } } Harl::~Harl() {}