Harl.cpp
1 /* ************************************************************************** */ 2 /* */ 3 /* ::: :::::::: */ 4 /* Harl.cpp :+: :+: :+: */ 5 /* +:+ +:+ +:+ */ 6 /* By: gychoi <gychoi@student.42seoul.kr> +#+ +:+ +#+ */ 7 /* +#+#+#+#+#+ +#+ */ 8 /* Created: 2023/07/28 01:14:21 by gychoi #+# #+# */ 9 /* Updated: 2023/07/28 16:44:12 by gychoi ### ########.fr */ 10 /* */ 11 /* ************************************************************************** */ 12 13 #include "Harl.hpp" 14 15 void Harl::debug(void) 16 { 17 std::cout << "I love having extra bacon for my 7XL-double-cheese-triple-pickle-special-ketchup burger. I really do!" << std::endl; 18 } 19 20 void Harl::info(void) 21 { 22 std::cout << "I cannot believe adding extra bacon costs more money. You didn’t put enough bacon in my burger! If you did, I wouldn’t be asking for more!" << std::endl; 23 } 24 25 void Harl::warning(void) 26 { 27 std::cout << "I think I deserve to have some extra bacon for free. I’ve been coming for years whereas you started working here since last month." << std::endl; 28 } 29 30 void Harl::error(void) 31 { 32 std::cout << "This is unacceptable! I want to speak to the manager now." << std::endl; 33 } 34 35 typedef void (Harl::*HARL_LEVEL)(void); 36 37 void Harl::complain(std::string level) 38 { 39 std::string levels[LEVEL_SIZE] = {"DEBUG", "INFO", "WARNING", "ERROR"}; 40 HARL_LEVEL harlLevel[LEVEL_SIZE]; 41 42 harlLevel[DEBUG] = &Harl::debug; 43 harlLevel[INFO] = &Harl::info; 44 harlLevel[WARNING] = &Harl::warning; 45 harlLevel[ERROR] = &Harl::error; 46 47 for (int i = 0; i < LEVEL_SIZE; i++) 48 { 49 if (levels[i] == level) 50 { 51 (this->*harlLevel[i])(); 52 break; 53 } 54 } 55 }