diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-04-13 10:33:05 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-04-13 10:33:05 +0200 |
| commit | 0f3240844dbd5a874e1565a988ef355ededab6a5 (patch) | |
| tree | efc1a1307863d173be17a12fbab6b84fe7d00960 /cpp01/ex03/ZombieHorde.cpp | |
| parent | 629d52b1262879a346e9ca17567a8f483c60ba0a (diff) | |
| download | piscine_cpp-0f3240844dbd5a874e1565a988ef355ededab6a5.tar.gz piscine_cpp-0f3240844dbd5a874e1565a988ef355ededab6a5.tar.bz2 piscine_cpp-0f3240844dbd5a874e1565a988ef355ededab6a5.zip | |
Fixing cpp01
Diffstat (limited to 'cpp01/ex03/ZombieHorde.cpp')
| -rw-r--r-- | cpp01/ex03/ZombieHorde.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/cpp01/ex03/ZombieHorde.cpp b/cpp01/ex03/ZombieHorde.cpp index e8218b4..955355b 100644 --- a/cpp01/ex03/ZombieHorde.cpp +++ b/cpp01/ex03/ZombieHorde.cpp @@ -1,7 +1,19 @@ -#include <cstdlib> +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ZombieHorde.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2020/04/13 09:52:11 by charles #+# #+# */ +/* Updated: 2020/04/13 10:02:01 by charles ### ########.fr */ +/* */ +/* ************************************************************************** */ + #include "ZombieHorde.hpp" -ZombieHorde::ZombieHorde(int size) +ZombieHorde::ZombieHorde(int n) + : m_size(n) { std::string name_pool[10] = { "Jordan", @@ -21,21 +33,20 @@ ZombieHorde::ZombieHorde(int size) "earth", "wind" }; - horde = new Zombie*[size]; - horde_size = size; - for (int i = 0; i < size; i++) - horde[i] = new Zombie(name_pool[rand() % 10], type_pool[rand() % 4]); + m_horde = new Zombie*[m_size]; + for (size_t i = 0; i < m_size; i++) + m_horde[i] = new Zombie(name_pool[rand() % 10], type_pool[rand() % 4]); } ZombieHorde::~ZombieHorde() { - for (int i = 0; i < horde_size; i++) - delete horde[i]; - delete [] horde; + for (size_t i = 0; i < m_size; i++) + delete m_horde[i]; + delete [] m_horde; } void ZombieHorde::announce() { - for (int i = 0; i < horde_size; i++) - horde[i]->announce(); + for (size_t i = 0; i < m_size; i++) + m_horde[i]->announce(); } |
