-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKaren.cpp
69 lines (60 loc) · 2.31 KB
/
Karen.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Karen.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: aperez-b <aperez-b@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/21 13:56:03 by aperez-b #+# #+# */
/* Updated: 2022/05/21 20:16:17 by aperez-b ### ########.fr */
/* */
/* ************************************************************************** */
#include "Karen.hpp"
Karen::Karen(void)
{
std::cout << "A wild Karen has appeared!" << std::endl;
}
Karen::~Karen(void)
{
std::cout << "Wild Karen flew away!" << std::endl;
}
void Karen::debug(void)
{
std::cout << MAGENTA << "[DEBUG] " << DEFAULT;
std::cout << "I love to get extra bacon for my ";
std::cout << "7XL-double-cheese-triple-pickle-special-ketchup burger.";
std::cout << " I just love it!" << std::endl;
}
void Karen::info(void)
{
std::cout << GRAY << "[INFO] " << DEFAULT;
std::cout << "I cannot believe adding extra bacon cost more money.";
std::cout << " You don’t put enough! If you did I would not have to ask";
std::cout << " for it!" << std::endl;
}
void Karen::warning(void)
{
std::cout << YELLOW << "[WARNING] " << DEFAULT;
std::cout << "I think I deserve to have some extra bacon for free.";
std::cout << " I’ve been coming here for years and you just started ";
std::cout << "working here last month." << std::endl;
}
void Karen::error(void)
{
std::cout << RED << "[ERROR] " << DEFAULT;
std::cout << "This is unacceptable, I want to speak to the manager now.";
std::cout << std::endl;
}
void Karen::complain(std::string level)
{
void (Karen::*ptr_complain[4])(void) = {&Karen::debug, &Karen::info, &Karen::warning, &Karen::error};
std::string levels[4] = {"DEBUG", "INFO", "WARNING", "ERROR"};
for (int i = 0; i < 4; i++)
{
if (levels[i] == level)
{
(this->*ptr_complain[i])();
break ;
}
}
}