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 <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 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 <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; +} 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 <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); 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 <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); +} 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 <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); +} 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 <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(); +}