diff --git a/ex00/.gitignore b/ex00/.gitignore new file mode 100644 index 0000000..5d61c98 --- /dev/null +++ b/ex00/.gitignore @@ -0,0 +1 @@ +ex00 diff --git a/ex00/Makefile b/ex00/Makefile index b499336..f95a5ea 100644 --- a/ex00/Makefile +++ b/ex00/Makefile @@ -9,7 +9,12 @@ endif ifeq ($(CXX),g++) CXX = c++ endif -main_objs = $(addsuffix .o,$(NAME)) +srcs = \ + Zombie.cpp \ + newZombie.cpp \ + randomChump.cpp \ + +main_objs = main.o $(srcs:.cpp=.o) all_objs = $(main_objs) deps = $(all_objs:.o=.d) diff --git a/ex00/Zombie.cpp b/ex00/Zombie.cpp new file mode 100644 index 0000000..df669d1 --- /dev/null +++ b/ex00/Zombie.cpp @@ -0,0 +1,10 @@ +#include "Zombie.hpp" +#include + +void Zombie::announce(void) { + std::cout << name << ": " << "BraiiiiiiinnnzzzZ..." << std::endl; +} + +Zombie::Zombie(std::string name) { this->name = name; } + +Zombie::~Zombie() { std::cout << name << " is heading out." << std::endl; } diff --git a/ex00/Zombie.hpp b/ex00/Zombie.hpp new file mode 100644 index 0000000..90ebabd --- /dev/null +++ b/ex00/Zombie.hpp @@ -0,0 +1,20 @@ +#ifndef ZOMBIE_HPP +#define ZOMBIE_HPP + +#include + +class Zombie { +public: + Zombie(std::string name); + ~Zombie(); + + void announce(void); + +private: + std::string name; +}; + +Zombie *newZombie(std::string name); +void randomChump(std::string name); + +#endif diff --git a/ex00/main.cpp b/ex00/main.cpp new file mode 100644 index 0000000..7490d56 --- /dev/null +++ b/ex00/main.cpp @@ -0,0 +1,8 @@ +#include "Zombie.hpp" +int main() { + Zombie *zombie = newZombie("Bob"); + zombie->announce(); + delete zombie; + randomChump("Alex"); + return 0; +} diff --git a/ex00/newZombie.cpp b/ex00/newZombie.cpp new file mode 100644 index 0000000..75b3f1f --- /dev/null +++ b/ex00/newZombie.cpp @@ -0,0 +1,6 @@ +#include "Zombie.hpp" + +Zombie *newZombie(std::string name) { + Zombie *zombie = new Zombie(name); + return zombie; +} diff --git a/ex00/randomChump.cpp b/ex00/randomChump.cpp new file mode 100644 index 0000000..bce25ee --- /dev/null +++ b/ex00/randomChump.cpp @@ -0,0 +1,6 @@ +#include "Zombie.hpp" + +void randomChump(std::string name) { + Zombie zombie = Zombie(name); + zombie.announce(); +}