1
0

」 feat(Brainnnz): Finished Brainzz

This commit is contained in:
2024-11-04 19:07:52 +01:00
parent 9d65e07bb0
commit 020261bc37
6 changed files with 175 additions and 0 deletions

57
ex00/Makefile Normal file
View File

@ -0,0 +1,57 @@
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/10/25 16:09:27 by adjoly #+# #+# #
# Updated: 2024/11/04 11:44:44 by adjoly ### ########.fr #
# #
# **************************************************************************** #
NAME = zombie
CC = c++
OBJSDIR = obj/
SRCS = main.cpp \
Zombie.cpp \
newZombie.cpp \
randomChump.cpp
OBJS = $(addprefix $(OBJSDIR), $(SRCS:.cpp=.o))
FLAGS = -Wall -Werror -Wextra -std=c++98 -MMD -MP
RED = \033[0;31m
GREEN = \033[0;32m
YELLOW = \033[1;33m
PURPLE = \e[0;35m
NC = \033[0m
DELETE = \x1B[2K\r
all: $(NAME)
$(NAME): $(OBJS)
@$(CC) $(FLAGS) $(OBJS) -o $(NAME)
@printf "$(YELLOW)「✨」($(NAME)) Program compiled\n"
$(OBJSDIR)%.o: %.cpp
@mkdir -p $(@D)
@$(CC) $(FLAGS) -c $< -o $@
@printf "$(DELETE)$(GREEN)「🔨」($<) Object compiled\n"
clean:
@rm -f $(OBJS)
@printf "$(DELETE)$(RED)「🗑️」($(OBJS)) Object deleted\n"
fclean: clean
@rm -f $(NAME)
@rm -Rf $(OBJSDIR)
@printf "$(RED)「🗑️」($(NAME)) Program deleted\n"
re: fclean all
.PHONY: clean fclean all re

27
ex00/Zombie.cpp Normal file
View File

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Zombie.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/04 11:40:41 by adjoly #+# #+# */
/* Updated: 2024/11/04 14:56:23 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "Zombie.hpp"
#include <iostream>
Zombie::Zombie(std::string name) {
this->name = name;
std::cout << this->name << " born" << std::endl;
}
Zombie::~Zombie(void) {
std::cout << this->name << " destroyed" << std::endl;
}
void Zombie::announce(void) {
std::cout << this->name << ": BraiiiiiiinnnzzzZ..." << std::endl;
}

27
ex00/Zombie.hpp Normal file
View File

@ -0,0 +1,27 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Zombie.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/04 10:52:33 by adjoly #+# #+# */
/* Updated: 2024/11/04 14:49:24 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include <string>
class Zombie {
private:
std::string name;
public:
void announce(void);
Zombie(std::string name);
~Zombie(void);
};
Zombie *newZombie(std::string name);
void randomChump(std::string name);

24
ex00/main.cpp Normal file
View File

@ -0,0 +1,24 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/04 11:41:07 by adjoly #+# #+# */
/* Updated: 2024/11/04 15:07:39 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "Zombie.hpp"
int main(void) {
Zombie *zombie;
zombie = newZombie("newZombieee");
zombie->announce();
delete zombie;
randomChump("Zombieee");
return (0);
}

22
ex00/newZombie.cpp Normal file
View File

@ -0,0 +1,22 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* newZombie.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/04 14:42:36 by adjoly #+# #+# */
/* Updated: 2024/11/04 14:49:42 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include <iostream>
#include "Zombie.hpp"
Zombie *newZombie(std::string name) {
Zombie *zombie;
zombie = new Zombie(name);
return (zombie);
}

18
ex00/randomChump.cpp Normal file
View File

@ -0,0 +1,18 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* randomChump.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/04 14:56:39 by adjoly #+# #+# */
/* Updated: 2024/11/04 14:57:22 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#include "Zombie.hpp"
void randomChump(std::string name) {
Zombie zombie(name);
zombie.announce();
}