From 368088666e4de671a3309a49cdd0dc6b2f30c003 Mon Sep 17 00:00:00 2001 From: Dominik Kaiser Date: Wed, 12 Feb 2025 11:36:46 +0100 Subject: [PATCH] Implement Harl --- ex05/Harl.cpp | 44 +++++++++++++++++++++++++++++++++++++++++++- ex05/Harl.hpp | 14 +++++++++++++- ex05/main.cpp | 14 ++++++++++++-- 3 files changed, 68 insertions(+), 4 deletions(-) diff --git a/ex05/Harl.cpp b/ex05/Harl.cpp index 91430f7..fcad030 100644 --- a/ex05/Harl.cpp +++ b/ex05/Harl.cpp @@ -6,8 +6,50 @@ /* By: dkaiser + +void Harl::complain(std::string level) +{ + std::string levels[4] = {"DEBUG", "INFO", "WARNING", "ERROR"}; + void (Harl::*funcs[4])() = {&Harl::debug, + &Harl::info, + &Harl::warning, + &Harl::error}; + for (int i = 0; i < 4; i++) + { + if (level == levels[i]) + (this->*funcs[i])(); + } +} + +void Harl::debug(void) +{ + std::cout << "I love having extra bacon for my "; + std::cout << "7XL-double-cheese-triple-pickle-special-ketchup burger. "; + std::cout << "I really do!" << std::endl; +} + +void Harl::info(void) +{ + std::cout << "I cannot believe adding extra bacon costs more money. "; + std::cout << "You didn’t put enough bacon in my burger! "; + std::cout << "If you did, I wouldn’t be asking for more!" << std::endl; +} + +void Harl::warning(void) +{ + std::cout << "I think I deserve to have some extra bacon for free. "; + std::cout << "I’ve been coming for years whereas you "; + std::cout << "started working here since last month." << std::endl; +} + +void Harl::error(void) +{ + std::cout << "This is unacceptable! I want to speak to the manager now."; + std::cout << std::endl; +} diff --git a/ex05/Harl.hpp b/ex05/Harl.hpp index a0b1f30..ade7f98 100644 --- a/ex05/Harl.hpp +++ b/ex05/Harl.hpp @@ -6,11 +6,23 @@ /* By: dkaiser +class Harl +{ + public: + void complain(std::string level); + private: + void debug(void); + void info(void); + void warning(void); + void error(void); +}; + #endif diff --git a/ex05/main.cpp b/ex05/main.cpp index 72a3752..1180187 100644 --- a/ex05/main.cpp +++ b/ex05/main.cpp @@ -6,9 +6,19 @@ /* By: dkaiser