Skip to content

Commit a2a2925

Browse files
committed
[WIP] First implementation of ex05
1 parent f105a64 commit a2a2925

File tree

10 files changed

+172
-10
lines changed

10 files changed

+172
-10
lines changed

ex00/Zombie.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: aperez-b <aperez-b@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2022/05/20 09:37:56 by aperez-b #+# #+# */
9-
/* Updated: 2022/05/20 10:58:44 by aperez-b ### ########.fr */
9+
/* Updated: 2022/05/21 13:59:22 by aperez-b ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -17,7 +17,7 @@
1717
# include <iostream>
1818

1919
/* Zombie Class definition */
20-
class Zombie
20+
class Zombie
2121
{
2222
private:
2323
std::string _name;

ex01/Zombie.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: aperez-b <aperez-b@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2022/05/20 09:37:56 by aperez-b #+# #+# */
9-
/* Updated: 2022/05/20 10:58:28 by aperez-b ### ########.fr */
9+
/* Updated: 2022/05/21 13:59:34 by aperez-b ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -18,7 +18,7 @@
1818
# include <algorithm>
1919

2020
/* Zombie Class definition */
21-
class Zombie
21+
class Zombie
2222
{
2323
private:
2424
std::string _name;

ex03/HumanA.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
/* By: aperez-b <aperez-b@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2022/05/20 11:41:39 by aperez-b #+# #+# */
9-
/* Updated: 2022/05/20 12:49:41 by aperez-b ### ########.fr */
9+
/* Updated: 2022/05/21 13:59:54 by aperez-b ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#include "Weapon.hpp"
1414

15-
class HumanA
15+
class HumanA
1616
{
1717
private:
1818
std::string _name;

ex03/HumanB.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
/* By: aperez-b <aperez-b@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2022/05/20 11:41:41 by aperez-b #+# #+# */
9-
/* Updated: 2022/05/20 15:23:39 by aperez-b ### ########.fr */
9+
/* Updated: 2022/05/21 14:00:00 by aperez-b ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

1313
#include "Weapon.hpp"
1414

15-
class HumanB
15+
class HumanB
1616
{
1717
private:
1818
std::string _name;

ex03/Weapon.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
/* By: aperez-b <aperez-b@student.42.fr> +#+ +:+ +#+ */
77
/* +#+#+#+#+#+ +#+ */
88
/* Created: 2022/05/20 11:30:53 by aperez-b #+# #+# */
9-
/* Updated: 2022/05/20 13:41:14 by aperez-b ### ########.fr */
9+
/* Updated: 2022/05/21 14:00:05 by aperez-b ### ########.fr */
1010
/* */
1111
/* ************************************************************************** */
1212

@@ -16,7 +16,7 @@
1616

1717
# include <iostream>
1818

19-
class Weapon
19+
class Weapon
2020
{
2121
private:
2222
std::string _type;

ex05/Karen

22 KB
Binary file not shown.

ex05/Karen.cpp

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

ex05/Karen.hpp

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* Karen.hpp :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: aperez-b <aperez-b@student.42.fr> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2022/05/21 13:56:06 by aperez-b #+# #+# */
9+
/* Updated: 2022/05/21 14:11:12 by aperez-b ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#ifndef KAREN_HPP
14+
15+
# define KAREN_HPP
16+
17+
# define DEFAULT "\001\033[0;39m\002"
18+
# define RED "\001\033[1;91m\002"
19+
# define YELLOW "\001\033[1;93m\002"
20+
# define MAGENTA "\001\033[1;95m\002"
21+
# define GRAY "\001\033[1;90m\002"
22+
23+
# include <iostream>
24+
25+
class Karen
26+
{
27+
private:
28+
void debug(void);
29+
void info(void);
30+
void warning(void);
31+
void error(void);
32+
public:
33+
Karen(void);
34+
~Karen(void);
35+
void complain(std::string level);
36+
};
37+
38+
#endif

ex05/Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# **************************************************************************** #
2+
# #
3+
# ::: :::::::: #
4+
# Makefile :+: :+: :+: #
5+
# +:+ +:+ +:+ #
6+
# By: aperez-b <aperez-b@student.42.fr> +#+ +:+ +#+ #
7+
# +#+#+#+#+#+ +#+ #
8+
# Created: 2022/03/14 14:11:00 by aperez-b #+# #+# #
9+
# Updated: 2022/05/21 13:56:28 by aperez-b ### ########.fr #
10+
# #
11+
# **************************************************************************** #
12+
13+
SRC = main.cpp Karen.cpp
14+
OBJ = $(SRC:.cpp=.o)
15+
CC = g++
16+
RM = rm -f
17+
CPPFLAGS = -Wall -Wextra -Werror -std=c++98 -pedantic
18+
19+
NAME = Karen
20+
21+
all: $(NAME)
22+
23+
$(NAME): $(OBJ)
24+
$(CC) $(CPPFLAGS) $(OBJ) -o $(NAME)
25+
26+
clean:
27+
$(RM) $(OBJ)
28+
29+
fclean: clean
30+
$(RM) $(NAME)
31+
32+
re: fclean $(NAME)
33+
34+
.PHONY: all clean fclean re

ex05/main.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* ************************************************************************** */
2+
/* */
3+
/* ::: :::::::: */
4+
/* main.cpp :+: :+: :+: */
5+
/* +:+ +:+ +:+ */
6+
/* By: aperez-b <aperez-b@student.42.fr> +#+ +:+ +#+ */
7+
/* +#+#+#+#+#+ +#+ */
8+
/* Created: 2022/05/21 13:55:25 by aperez-b #+# #+# */
9+
/* Updated: 2022/05/21 14:25:28 by aperez-b ### ########.fr */
10+
/* */
11+
/* ************************************************************************** */
12+
13+
#include "Karen.hpp"
14+
15+
int main(void)
16+
{
17+
Karen k;
18+
19+
k.complain("DEBUG");
20+
k.complain("INFO");
21+
k.complain("WARNING");
22+
k.complain("ERROR");
23+
return (0);
24+
}

0 commit comments

Comments
 (0)