Utilisation de pointeur de pointeur pour l'univers + affichage de l'univers

This commit is contained in:
Mylloon 2022-04-02 13:36:11 +02:00
parent 7971c8b4f1
commit e419f323f9
Signed by: Anri
GPG key ID: A82D63DFF8D1317F

View file

@ -1,7 +1,7 @@
#include "univers.hpp" #include "univers.hpp"
void lancerSimulation(Univers * univers, int m, int n, int nb_moutons, int nb_loups) { void lancerSimulation(Univers ** univers, int m, int n, int nb_moutons, int nb_loups) {
univers = new Univers(m, n); *univers = new Univers(m, n);
std::vector<Animal*> animaux; std::vector<Animal*> animaux;
@ -14,7 +14,7 @@ void lancerSimulation(Univers * univers, int m, int n, int nb_moutons, int nb_lo
nb_loups--; nb_loups--;
} }
univers->ajoutAnimaux(animaux); (*univers)->ajoutAnimaux(animaux);
} }
void arreterSimulation(Univers * univers) { void arreterSimulation(Univers * univers) {
@ -46,7 +46,9 @@ int main(int argc, char const *argv[]) {
Univers * univers = nullptr; Univers * univers = nullptr;
try { try {
lancerSimulation(univers, m, n, nb_moutons, nb_loups); lancerSimulation(&univers, m, n, nb_moutons, nb_loups);
univers->affichage();
arreterSimulation(univers); arreterSimulation(univers);
} catch(const std::exception& e) { } catch(const std::exception& e) {