harl.class.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* harl.class.cpp :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@gmail.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2025/07/15 19:49:59 by bchanot #+# #+# */
  9. /* Updated: 2025/07/16 13:29:14 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "harl.class.hpp"
  13. void Harl::debug(void) {
  14. std::cout << "[DEBUG] I love having extra bacon for my 7XL-double-cheese-triple-pickle-special-ketchup burger. I really do!" << std::endl;
  15. }
  16. void Harl::info(void) {
  17. std::cout << "[INFO] 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;
  18. }
  19. void Harl::warning(void) {
  20. std::cout << "[WARNING] I think I deserve to have some extra bacon for free. I’ve been coming for years, whereas you started working here just last month." << std::endl;
  21. }
  22. void Harl::error(void) {
  23. std::cout << "[ERROR] This is unacceptable! I want to speak to the manager now." << std::endl;
  24. }
  25. void Harl::complain(std::string level) {
  26. void (Harl::*fn[])(void) = {&Harl::debug, &Harl::info, &Harl::warning, &Harl::error};
  27. std::string complain[] = {"DEBUG", "INFO", "WARNING", "ERROR"};
  28. int i;
  29. bool print = false;
  30. i = 0;
  31. while (i < 4) {
  32. if (complain[i].compare(level) == 0 || print) {
  33. print = true;
  34. (this->*fn[i])();
  35. }
  36. i++;
  37. }
  38. }