Utilisation de pointeur de pointeur pour l'univers + affichage de l'univers
This commit is contained in:
parent
7971c8b4f1
commit
e419f323f9
1 changed files with 6 additions and 4 deletions
10
main.cpp
10
main.cpp
|
@ -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) {
|
||||||
|
|
Reference in a new issue