ex05 added newline and ex06 done

This commit is contained in:
Angel Ortigosa Perez
2025-09-07 10:25:48 +02:00
parent a40a112989
commit c099aa5136
5 changed files with 164 additions and 0 deletions

77
ex06/Harl/Harl.cpp Normal file
View File

@@ -0,0 +1,77 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Harl.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/09/06 02:27:27 by aortigos #+# #+# */
/* Updated: 2025/09/06 02:28:09 by aortigos ### ########.fr */
/* */
/* ************************************************************************** */
#include "Harl.hpp"
void Harl::debug( void )
{
std::cout << "[ DEBUG ]" << std::endl;
std::cout << "I love having extra bacon for my 7XL-double-cheese-triple-pickle-specialketchup burger. I really do!";
std::cout << std::endl << std::endl;
}
void Harl::info( void )
{
std::cout << "[ INFO ]" << std::endl;
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::cout << std::endl << std::endl;
}
void Harl::warning( void )
{
std::cout << "[ WARNING ]" << std::endl;
std::cout << "I think I deserve to have some extra bacon for free. Ive been coming for years, whereas you started working here just last month.";
std::cout << std::endl << std::endl;
}
void Harl::error( void )
{
std::cout << "[ ERROR ]" << std::endl;
std::cout << "This is unacceptable! I want to speak to the manager now.";
std::cout << std::endl << std::endl;
}
void Harl::complain( std::string level )
{
int i;
typedef void (Harl::*HarlFunc)();
i = 0;
std::string levels[]= {"DEBUG", "INFO", "WARNING", "ERROR"};
HarlFunc funcs[] = { &Harl::debug, &Harl::info, &Harl::warning, &Harl::error};
while (i < 4)
{
if (level == levels[i])
break;
i++;
}
switch (i)
{
case 0:
(this->*funcs[i++])();
/* fall through */
case 1:
(this->*funcs[i++])();
/* fall through */
case 2:
(this->*funcs[i++])();
/* fall through */
case 3:
(this->*funcs[i])();
/* fall through */
break;
default:
std::cout << "[ Probably complaining about insignificant problems ]" << std::endl;;
break;
}
}