1
0
This repository has been archived on 2024-11-25. You can view files and clone it, but cannot push or open issues or pull requests.
CPP_Module_01/ex05/harl.cpp

43 lines
1.9 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* harl.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/09 17:15:01 by adjoly #+# #+# */
/* Updated: 2024/11/09 17:39:12 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "harl.hpp"
#include <iostream>
void Harl::complain(std::string level) {
std::string complainLevel[4] = {"DEBUG", "INFO", "WARNING", "ERROR"};
void (Harl::*func[4])(void) = {&Harl::debug, &Harl::info, &Harl::warning, &Harl::error};
uint8_t i = 0;
while (i < 4 && level != complainLevel[i])
i++;
if (i < 4)
(this->*func[i])();
return ;
}
void Harl::debug(void) {
std::cout << "I love having extra bacon for my 7XL-double-cheese-triple-pickle-specialketchup burger. I really do!" << std::endl;
}
void Harl::info(void) {
std::cout << "I cannot believe adding extra bacon costs more money. You didnt put enough bacon in my burger! If you did, I wouldnt be asking for more!" << std::endl;
}
void Harl::warning(void) {
std::cout << "I think I deserve to have some extra bacon for free. Ive been coming for years whereas you 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::endl;
}