diff --git a/d00/fr.subject.pdf b/d00/fr.subject.pdf new file mode 100644 index 0000000..d6439de Binary files /dev/null and b/d00/fr.subject.pdf differ diff --git a/d01/ex01/Makefile b/d01/ex01/Makefile new file mode 100644 index 0000000..e9fbfcd --- /dev/null +++ b/d01/ex01/Makefile @@ -0,0 +1,63 @@ +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # +# . name = value . name is case sensitive # +# VARIABLES . or name = value \ . use VPATH only for .c # +# . value . or .cpp # +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # + +NAME = zombie + +CC = clang++ +CFLAGS = -Wall -Wextra -Werror $(INCLUDES) -std=c++98 -g3 + +VPATH = $(D_SRCS) + +LIBS = + +INCLUDES = -I$(D_HEADERS) + +D_SRCS = . +SRCS = main.cpp \ + Zombie.cpp \ + ZombieHorde.cpp + +D_HEADERS = . +HEADERS = Zombie.hpp + +D_OBJS = builds +OBJS = $(SRCS:%.cpp=$(D_OBJS)/%.o) + +RM_D_OBJS = rm -rf $(D_OBJS) +ifeq "$(D_OBJS)" "." +RM_D_OBJS = +endif + + +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # +# . target: prerequisites . $@ : target # +# RULES . recipe . $< : 1st prerequisite # +# . recipe . $^ : all prerequisites # +# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # + +all: $(NAME) + +$(D_OBJS)/%.o: %.cpp | $(D_OBJS) + $(CC) $(CFLAGS) -c $< -o $@ + +$(D_OBJS): + mkdir $@ + +$(OBJS): $(HEADERS:%=$(D_HEADERS)/%) + +$(NAME): $(OBJS) + $(CC) $(OBJS) -o $@ $(LIBS) + +clean: + rm -f $(OBJS) + +fclean: clean + rm -f $(NAME) + $(RM_D_OBJS) + +re: fclean all + +.PHONY : all clean fclean re bonus run valgrind diff --git a/d01/ex01/Zombie.cpp b/d01/ex01/Zombie.cpp new file mode 100644 index 0000000..dfb1eba --- /dev/null +++ b/d01/ex01/Zombie.cpp @@ -0,0 +1,26 @@ +#include "Zombie.hpp" + +Zombie::Zombie() { + + std::cout << this->_name << " has been created" << std::endl; + +} + +Zombie::~Zombie() { + + std::cout << this->_name << " has been destroyed" << std::endl; + +} + +void Zombie::announce( void ) { + + std::cout << this->_name << ": BraiiiiiiinnnzzzZ..." << std::endl; + +} + +void Zombie::put_name( std::string name ) { + + this->_name = name; + +} + diff --git a/d01/ex01/Zombie.hpp b/d01/ex01/Zombie.hpp new file mode 100644 index 0000000..5df4cdf --- /dev/null +++ b/d01/ex01/Zombie.hpp @@ -0,0 +1,23 @@ +#ifndef ZOMBIE_HPP +# define ZOMBIE_HPP + +#include +#include + +class Zombie { + +public: + + Zombie(); + ~Zombie(); + + void announce( void ); + void put_name( std::string name ); + +private: + + std::string _name; + +}; + +#endif diff --git a/d01/ex01/ZombieHorde.cpp b/d01/ex01/ZombieHorde.cpp new file mode 100644 index 0000000..1c400eb --- /dev/null +++ b/d01/ex01/ZombieHorde.cpp @@ -0,0 +1,12 @@ +#include "Zombie.hpp" + +Zombie* zombieHorde( int N, std::string name ) { + + Zombie *zomboz = new Zombie[N]; + + for (int i = 0; i < N; i++) + zomboz[i].put_name( name ); + + return zomboz; + +} diff --git a/d01/ex01/main.cpp b/d01/ex01/main.cpp new file mode 100644 index 0000000..4fb1aa8 --- /dev/null +++ b/d01/ex01/main.cpp @@ -0,0 +1,17 @@ +#include "Zombie.hpp" + +Zombie* zombieHorde( int N, std::string name ); +#define z_nb 8 + +int main(void) +{ + Zombie* zombi; + + zombi = zombieHorde( z_nb, "rambou" ); + for (int i = 0; i < z_nb; i++) { + zombi[i].announce(); + } + delete [] zombi; + + return (0); +} diff --git a/d01/fr.subject.pdf b/d01/fr.subject.pdf new file mode 100644 index 0000000..a46c99f Binary files /dev/null and b/d01/fr.subject.pdf differ