diff options
| author | Charles <sircharlesaze@gmail.com> | 2020-01-12 20:20:12 +0100 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2020-01-12 20:20:12 +0100 |
| commit | 7d6a4c877de8048ec5fbea4a563b3d09c8976105 (patch) | |
| tree | a62206e21b3b678d0da6350978e2f6db7cc31fbe /cpp01/ex03/ZombieHorde.cpp | |
| parent | 7080f89bb2800917bfd9a560046a1ab7505f819e (diff) | |
| download | piscine_cpp-7d6a4c877de8048ec5fbea4a563b3d09c8976105.tar.gz piscine_cpp-7d6a4c877de8048ec5fbea4a563b3d09c8976105.tar.bz2 piscine_cpp-7d6a4c877de8048ec5fbea4a563b3d09c8976105.zip | |
cpp01 00 -> 04
Diffstat (limited to 'cpp01/ex03/ZombieHorde.cpp')
| -rw-r--r-- | cpp01/ex03/ZombieHorde.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/cpp01/ex03/ZombieHorde.cpp b/cpp01/ex03/ZombieHorde.cpp new file mode 100644 index 0000000..e8218b4 --- /dev/null +++ b/cpp01/ex03/ZombieHorde.cpp @@ -0,0 +1,41 @@ +#include <cstdlib> +#include "ZombieHorde.hpp" + +ZombieHorde::ZombieHorde(int size) +{ + std::string name_pool[10] = { + "Jordan", + "Mr.poopybutthole", + "Jean-Denis", + "Table", + "Charle", + "Abe", + "James", + "Homer", + "yo", + "rideaux" + }; + std::string type_pool[4] = { + "fire", + "water", + "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]); +} + +ZombieHorde::~ZombieHorde() +{ + for (int i = 0; i < horde_size; i++) + delete horde[i]; + delete [] horde; +} + +void ZombieHorde::announce() +{ + for (int i = 0; i < horde_size; i++) + horde[i]->announce(); +} |
