From 020261bc372422f7612239e6cba00f1e01afc84e Mon Sep 17 00:00:00 2001 From: Adam JOLY Date: Mon, 4 Nov 2024 19:07:52 +0100 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=E2=9C=A8=E3=80=8D=20feat(Brainnnz):?= =?UTF-8?q?=20Finished=20Brainzz?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ex00/Makefile | 57 ++++++++++++++++++++++++++++++++++++++++++++ ex00/Zombie.cpp | 27 +++++++++++++++++++++ ex00/Zombie.hpp | 27 +++++++++++++++++++++ ex00/main.cpp | 24 +++++++++++++++++++ ex00/newZombie.cpp | 22 +++++++++++++++++ ex00/randomChump.cpp | 18 ++++++++++++++ 6 files changed, 175 insertions(+) create mode 100644 ex00/Makefile create mode 100644 ex00/Zombie.cpp create mode 100644 ex00/Zombie.hpp create mode 100644 ex00/main.cpp create mode 100644 ex00/newZombie.cpp create mode 100644 ex00/randomChump.cpp diff --git a/ex00/Makefile b/ex00/Makefile new file mode 100644 index 0000000..7058cd0 --- /dev/null +++ b/ex00/Makefile @@ -0,0 +1,57 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: adjoly +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# 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 diff --git a/ex00/Zombie.cpp b/ex00/Zombie.cpp new file mode 100644 index 0000000..a9cd358 --- /dev/null +++ b/ex00/Zombie.cpp @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Zombie.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/04 11:40:41 by adjoly #+# #+# */ +/* Updated: 2024/11/04 14:56:23 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Zombie.hpp" +#include + +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; +} diff --git a/ex00/Zombie.hpp b/ex00/Zombie.hpp new file mode 100644 index 0000000..1b89ba2 --- /dev/null +++ b/ex00/Zombie.hpp @@ -0,0 +1,27 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Zombie.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/04 10:52:33 by adjoly #+# #+# */ +/* Updated: 2024/11/04 14:49:24 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once + +#include +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); diff --git a/ex00/main.cpp b/ex00/main.cpp new file mode 100644 index 0000000..a705358 --- /dev/null +++ b/ex00/main.cpp @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/ex00/newZombie.cpp b/ex00/newZombie.cpp new file mode 100644 index 0000000..c037314 --- /dev/null +++ b/ex00/newZombie.cpp @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* newZombie.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/04 14:42:36 by adjoly #+# #+# */ +/* Updated: 2024/11/04 14:49:42 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include "Zombie.hpp" + +Zombie *newZombie(std::string name) { + Zombie *zombie; + + zombie = new Zombie(name); + + return (zombie); +} diff --git a/ex00/randomChump.cpp b/ex00/randomChump.cpp new file mode 100644 index 0000000..85ef618 --- /dev/null +++ b/ex00/randomChump.cpp @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* randomChump.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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(); +}