From 197744804dc954f6714ee5e251317922c6c3344e Mon Sep 17 00:00:00 2001 From: Adam JOLY Date: Mon, 4 Nov 2024 20:19:12 +0100 Subject: [PATCH] =?UTF-8?q?=E3=80=8C=F0=9F=8F=97=EF=B8=8F=E3=80=8D=20wip(U?= =?UTF-8?q?nnecessary=20violence):=20Started=20ex03?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ex00/Zombie.hpp | 4 +++- ex01/Zombie.hpp | 3 ++- ex03/HumanA.cpp | 18 +++++++++++++++++ ex03/HumanA.hpp | 25 +++++++++++++++++++++++ ex03/HumanB.cpp | 22 ++++++++++++++++++++ ex03/HumanB.hpp | 26 ++++++++++++++++++++++++ ex03/Makefile | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ ex03/Weapon.cpp | 21 +++++++++++++++++++ ex03/Weapon.hpp | 24 ++++++++++++++++++++++ ex03/main.cpp | 15 ++++++++++++++ 10 files changed, 210 insertions(+), 2 deletions(-) create mode 100644 ex03/HumanA.cpp create mode 100644 ex03/HumanA.hpp create mode 100644 ex03/HumanB.cpp create mode 100644 ex03/HumanB.hpp create mode 100644 ex03/Makefile create mode 100644 ex03/Weapon.cpp create mode 100644 ex03/Weapon.hpp create mode 100644 ex03/main.cpp diff --git a/ex00/Zombie.hpp b/ex00/Zombie.hpp index 1b89ba2..4df9510 100644 --- a/ex00/Zombie.hpp +++ b/ex00/Zombie.hpp @@ -6,16 +6,18 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/04 10:52:33 by adjoly #+# #+# */ -/* Updated: 2024/11/04 14:49:24 by adjoly ### ########.fr */ +/* Updated: 2024/11/04 19:21:59 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ #pragma once #include + class Zombie { private: std::string name; + public: void announce(void); diff --git a/ex01/Zombie.hpp b/ex01/Zombie.hpp index b854fb0..26a4622 100644 --- a/ex01/Zombie.hpp +++ b/ex01/Zombie.hpp @@ -6,7 +6,7 @@ /* By: adjoly +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2024/11/04 10:52:33 by adjoly #+# #+# */ -/* Updated: 2024/11/04 18:54:32 by adjoly ### ########.fr */ +/* Updated: 2024/11/04 19:22:07 by adjoly ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,6 +19,7 @@ class Zombie { private: std::string name; + public: void announce(void); void setName(std::string newName); diff --git a/ex03/HumanA.cpp b/ex03/HumanA.cpp new file mode 100644 index 0000000..f89332a --- /dev/null +++ b/ex03/HumanA.cpp @@ -0,0 +1,18 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* HumanA.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/04 19:41:23 by adjoly #+# #+# */ +/* Updated: 2024/11/04 19:42:58 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include +#include "HumanA.hpp" + +void HumanA::attack(void) { + std::cout << this->name << " attacks with their " << this->weapon.getType() << std::endl; +} diff --git a/ex03/HumanA.hpp b/ex03/HumanA.hpp new file mode 100644 index 0000000..bbdf8ce --- /dev/null +++ b/ex03/HumanA.hpp @@ -0,0 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* HumanA.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/04 19:36:00 by adjoly #+# #+# */ +/* Updated: 2024/11/04 19:40:02 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once + +#include "Weapon.hpp" +#include + +class HumanA { + private: + std::string name; + Weapon weapon; + + public: + void attack(void); +}; diff --git a/ex03/HumanB.cpp b/ex03/HumanB.cpp new file mode 100644 index 0000000..ecc6fa5 --- /dev/null +++ b/ex03/HumanB.cpp @@ -0,0 +1,22 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* HumanB.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/04 19:43:18 by adjoly #+# #+# */ +/* Updated: 2024/11/04 19:50:18 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "HumanB.hpp" +#include + +void HumanB::attack(void) { + std::cout << this->name << " attacks with their " << this->weapon.getType() << std::endl; +} + +void HumanB::setWeapon(Weapon newWeapon) { + this->weapon = newWeapon; +} diff --git a/ex03/HumanB.hpp b/ex03/HumanB.hpp new file mode 100644 index 0000000..6c347b9 --- /dev/null +++ b/ex03/HumanB.hpp @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* HumanB.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/04 19:39:47 by adjoly #+# #+# */ +/* Updated: 2024/11/04 19:50:19 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once + +#include "Weapon.hpp" +#include + +class HumanB { + private: + std::string name; + Weapon weapon; + + public: + void attack(void); + void setWeapon(Weapon newWeapon); +}; diff --git a/ex03/Makefile b/ex03/Makefile new file mode 100644 index 0000000..61e7448 --- /dev/null +++ b/ex03/Makefile @@ -0,0 +1,54 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: adjoly +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2024/10/25 16:09:27 by adjoly #+# #+# # +# Updated: 2024/11/04 19:17:30 by adjoly ### ########.fr # +# # +# **************************************************************************** # + +NAME = violence + +CC = c++ + +OBJSDIR = obj/ + +SRCS = main.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/ex03/Weapon.cpp b/ex03/Weapon.cpp new file mode 100644 index 0000000..4546d85 --- /dev/null +++ b/ex03/Weapon.cpp @@ -0,0 +1,21 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Weapon.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/04 19:23:35 by adjoly #+# #+# */ +/* Updated: 2024/11/04 19:34:02 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Weapon.hpp" + +void Weapon::setType(std::string newType) { + this->type = newType; +} + +std::string Weapon::getType(void) { + return (this->type); +} diff --git a/ex03/Weapon.hpp b/ex03/Weapon.hpp new file mode 100644 index 0000000..61fce9f --- /dev/null +++ b/ex03/Weapon.hpp @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Weapon.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/04 19:21:24 by adjoly #+# #+# */ +/* Updated: 2024/11/04 19:23:25 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once + +#include + +class Weapon { + private: + std::string type; + + public: + std::string getType(void); + void setType(std::string newType); +}; diff --git a/ex03/main.cpp b/ex03/main.cpp new file mode 100644 index 0000000..c7c6a2a --- /dev/null +++ b/ex03/main.cpp @@ -0,0 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: adjoly +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/11/04 19:20:57 by adjoly #+# #+# */ +/* Updated: 2024/11/04 19:21:10 by adjoly ### ########.fr */ +/* */ +/* ************************************************************************** */ + +int main(void) { + +}