2022-03-31 13:31:37 +02:00
|
|
|
#ifndef _UNIVERS_HPP_
|
|
|
|
#define _UNIVERS_HPP_ 1
|
|
|
|
|
2022-04-01 23:43:58 +02:00
|
|
|
#include <iostream>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class Organisme;
|
2022-04-02 01:39:36 +02:00
|
|
|
class Animal;
|
2022-04-01 23:43:58 +02:00
|
|
|
|
2022-03-31 13:31:37 +02:00
|
|
|
class Univers {
|
2022-03-31 16:09:34 +02:00
|
|
|
friend class Organisme;
|
|
|
|
|
2022-04-02 01:39:36 +02:00
|
|
|
const int _m, _n, _tailleUnivers, _tailleMax;
|
|
|
|
int _tour, _nbAnimaux;
|
2022-03-31 16:09:34 +02:00
|
|
|
int * _plateau;
|
2022-03-31 13:31:37 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
Univers(int, int);
|
2022-04-02 00:46:38 +02:00
|
|
|
~Univers(void);
|
2022-04-01 23:43:58 +02:00
|
|
|
|
2022-04-02 01:39:36 +02:00
|
|
|
// Ajoute des animaux à l'univers
|
|
|
|
void ajoutAnimaux(std::vector<Animal*>);
|
2022-04-02 00:46:38 +02:00
|
|
|
|
2022-04-02 01:39:36 +02:00
|
|
|
/* Ajoute un organisme
|
|
|
|
* Attention, écrase l'organisme précédent */
|
|
|
|
void ajoutOrganisme(Organisme *, int);
|
|
|
|
|
|
|
|
// Affiche l'univers à l'instant présent
|
|
|
|
void affichage(void);
|
|
|
|
|
|
|
|
// Vérifie s'il y a de la vie dans l'univers
|
|
|
|
bool enVie(void) const noexcept;
|
2022-03-31 13:31:37 +02:00
|
|
|
};
|
|
|
|
|
2022-03-31 16:09:34 +02:00
|
|
|
class Organisme {
|
|
|
|
public:
|
|
|
|
Organisme(void);
|
2022-04-02 00:46:38 +02:00
|
|
|
|
2022-04-02 01:39:36 +02:00
|
|
|
/* Renvoie l'ID de l'organisme
|
|
|
|
* Si `ID < 0` -> non vivant
|
|
|
|
* Si `ID > 0` -> vivant
|
|
|
|
* Si `ID == 0` -> Herbe */
|
|
|
|
virtual int id(void) const noexcept = 0;
|
2022-03-31 16:09:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class Animal: public Organisme {
|
|
|
|
public:
|
|
|
|
Animal(void);
|
2022-04-01 23:43:58 +02:00
|
|
|
|
2022-04-02 00:46:38 +02:00
|
|
|
// Animal carnivore ?
|
2022-04-02 01:39:36 +02:00
|
|
|
virtual bool carnivore(void) const noexcept = 0;
|
2022-03-31 16:09:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class Herbe: public Organisme {
|
|
|
|
public:
|
|
|
|
Herbe(void);
|
2022-04-02 00:46:38 +02:00
|
|
|
|
|
|
|
// Représenté par "0" dans l'univers
|
2022-04-02 01:39:36 +02:00
|
|
|
int id(void) const noexcept;
|
2022-03-31 16:09:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
class Sel: public Organisme {
|
|
|
|
public:
|
|
|
|
Sel(void);
|
|
|
|
|
2022-04-02 01:48:38 +02:00
|
|
|
// Représenté par "-1" dans l'univers
|
2022-04-02 01:39:36 +02:00
|
|
|
int id(void) const noexcept;
|
2022-04-02 00:46:38 +02:00
|
|
|
};
|
2022-03-31 16:09:34 +02:00
|
|
|
|
|
|
|
class Mouton: public Animal {
|
|
|
|
public:
|
|
|
|
Mouton(void);
|
2022-04-01 23:43:58 +02:00
|
|
|
|
2022-04-02 01:39:36 +02:00
|
|
|
bool carnivore(void) const noexcept;
|
2022-04-02 00:46:38 +02:00
|
|
|
|
2022-04-02 01:48:38 +02:00
|
|
|
// Représenté par "1" dans l'univers
|
2022-04-02 01:39:36 +02:00
|
|
|
int id(void) const noexcept;
|
2022-03-31 16:09:34 +02:00
|
|
|
};
|
|
|
|
|
2022-04-02 00:46:38 +02:00
|
|
|
|
2022-04-01 23:43:58 +02:00
|
|
|
class Loup: public Animal {
|
2022-03-31 16:09:34 +02:00
|
|
|
public:
|
2022-04-01 23:43:58 +02:00
|
|
|
Loup(void);
|
|
|
|
|
2022-04-02 01:39:36 +02:00
|
|
|
bool carnivore(void) const noexcept;
|
2022-04-02 00:46:38 +02:00
|
|
|
|
2022-04-02 01:48:38 +02:00
|
|
|
// Représenté par "2" dans l'univers
|
2022-04-02 01:39:36 +02:00
|
|
|
int id(void) const noexcept;
|
2022-03-31 16:09:34 +02:00
|
|
|
};
|
|
|
|
|
2022-03-31 13:31:37 +02:00
|
|
|
#endif
|