diff options
Diffstat (limited to 'cpp01/ex02')
| -rw-r--r-- | cpp01/ex02/Zombie.cpp | 19 | ||||
| -rw-r--r-- | cpp01/ex02/Zombie.hpp | 26 | ||||
| -rw-r--r-- | cpp01/ex02/ZombieEvent.cpp | 25 | ||||
| -rw-r--r-- | cpp01/ex02/ZombieEvent.hpp | 29 | ||||
| -rw-r--r-- | cpp01/ex02/main.cpp | 16 |
5 files changed, 88 insertions, 27 deletions
diff --git a/cpp01/ex02/Zombie.cpp b/cpp01/ex02/Zombie.cpp index 2ea23b6..40fb849 100644 --- a/cpp01/ex02/Zombie.cpp +++ b/cpp01/ex02/Zombie.cpp @@ -1,14 +1,25 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Zombie.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/13 09:38:16 by charles #+# #+# */ +/* Updated: 2020/04/13 09:40:20 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include <iostream> #include "Zombie.hpp" -Zombie::Zombie(std::string n, std::string t) +Zombie::Zombie(std::string name, std::string type) + : m_name(name), m_type(type) { - name = n; - type = t; announce(); } void Zombie::announce() { - std::cout << "<" << name << " (" << type << ")> Braiiiiiiinnnssss..." << std::endl; + std::cout << "<" << m_name << " (" << m_type << ")> Braiiiiiiinnnssss..." << std::endl; } diff --git a/cpp01/ex02/Zombie.hpp b/cpp01/ex02/Zombie.hpp index 980ea49..5106c8f 100644 --- a/cpp01/ex02/Zombie.hpp +++ b/cpp01/ex02/Zombie.hpp @@ -1,17 +1,29 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Zombie.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/13 09:40:26 by charles #+# #+# */ +/* Updated: 2020/04/13 09:40:49 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + #ifndef ZOMBIE_HPP # define ZOMBIE_HPP -#include <string> +# include <string> class Zombie { - public: - Zombie(std::string n, std::string t); - void announce(); +public: + Zombie(std::string name, std::string type); + void announce(); - private: - std::string name; - std::string type; +private: + std::string m_name; + std::string m_type; }; #endif diff --git a/cpp01/ex02/ZombieEvent.cpp b/cpp01/ex02/ZombieEvent.cpp index 6775138..acb8dd0 100644 --- a/cpp01/ex02/ZombieEvent.cpp +++ b/cpp01/ex02/ZombieEvent.cpp @@ -1,17 +1,28 @@ -#include <cstdlib> +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ZombieEvent.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/13 09:41:33 by charles #+# #+# */ +/* Updated: 2020/04/13 09:49:36 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "ZombieEvent.hpp" -void ZombieEvent::setZombieType(std::string type) +void ZombieEvent::setZombieType(std::string storedType) { - stored_type = type; + m_storedType = storedType; } -Zombie *ZombieEvent::newZombie(std::string name) +Zombie* ZombieEvent::newZombie(std::string name) { - return new Zombie(name, stored_type); + return new Zombie(name, m_storedType); } -Zombie *ZombieEvent::randomChump() +Zombie* ZombieEvent::randomChump() { std::string pool[10] = { "Jordan", @@ -25,5 +36,5 @@ Zombie *ZombieEvent::randomChump() "yo", "rideaux" }; - return new Zombie(pool[rand() % 10], stored_type); + return new Zombie(pool[rand() % 10], m_storedType); } diff --git a/cpp01/ex02/ZombieEvent.hpp b/cpp01/ex02/ZombieEvent.hpp index 869207e..7b2fe79 100644 --- a/cpp01/ex02/ZombieEvent.hpp +++ b/cpp01/ex02/ZombieEvent.hpp @@ -1,18 +1,31 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ZombieEvent.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/13 09:42:36 by charles #+# #+# */ +/* Updated: 2020/04/13 09:45:36 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + #ifndef ZOMBIE_EVENT_HPP # define ZOMBIE_EVENT_HPP -#include <string> -#include "Zombie.hpp" +# include <string> +# include <cstdlib> +# include "Zombie.hpp" class ZombieEvent { - public: - void setZombieType(std::string type); - Zombie *newZombie(std::string name); - Zombie *randomChump(); +public: + void setZombieType(std::string type); + Zombie* newZombie(std::string name); + Zombie* randomChump(); - private: - std::string stored_type; +private: + std::string m_storedType; }; #endif diff --git a/cpp01/ex02/main.cpp b/cpp01/ex02/main.cpp index 1df20d2..291fddb 100644 --- a/cpp01/ex02/main.cpp +++ b/cpp01/ex02/main.cpp @@ -1,11 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/13 09:47:21 by charles #+# #+# */ +/* Updated: 2020/04/13 09:48:29 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include <cstdlib> #include "Zombie.hpp" #include "ZombieEvent.hpp" int main() { - Zombie *z; + Zombie* z; ZombieEvent zevent; + Zombie zStack("onTheStack", "IdontLikeHeap"); srand(time(NULL)); zevent.setZombieType("standard"); @@ -16,5 +29,6 @@ int main() z = zevent.randomChump(); delete z; } + return 0; } |
