- Includes
- Fonction carnivore
- Ajout d'organismes à l'univers
This commit is contained in:
Mylloon 2022-04-01 23:43:58 +02:00
parent 8071e2ade1
commit 4c937b5276
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 44 additions and 3 deletions

View file

@ -1,3 +1,31 @@
#include "univers.hpp" #include "univers.hpp"
Univers::Univers(int m, int n): _m(m), _n(n) { } // -------- Univers --------
Univers::Univers(int m, int n): _m(m), _n(n), _tour(0) {
_plateau = new int[m * n];
}
void Univers::ajoutOrganismes(std::vector<Organisme*> organismes) {
uint64_t tailleUnivers = _m * _n;
if(organismes.size() > tailleUnivers - tailleUnivers / 4)
throw std::domain_error("Trop d'organismes pour l'univers.\n");
}
// -------- Organisme --------
Organisme::Organisme(void) {
}
// -------- Mouton --------
bool Mouton::carnivore(void) {
return false;
}
// -------- Loup --------
bool Loup::carnivore(void) {
return false;
}

View file

@ -1,6 +1,11 @@
#ifndef _UNIVERS_HPP_ #ifndef _UNIVERS_HPP_
#define _UNIVERS_HPP_ 1 #define _UNIVERS_HPP_ 1
#include <iostream>
#include <vector>
class Organisme;
class Univers { class Univers {
friend class Organisme; friend class Organisme;
@ -9,6 +14,8 @@ class Univers {
public: public:
Univers(int, int); Univers(int, int);
void ajoutOrganismes(std::vector<Organisme*>);
}; };
class Organisme { class Organisme {
@ -19,6 +26,8 @@ class Organisme {
class Animal: public Organisme { class Animal: public Organisme {
public: public:
Animal(void); Animal(void);
virtual bool carnivore(void) = 0;
}; };
class Herbe: public Organisme { class Herbe: public Organisme {
@ -35,11 +44,15 @@ class Sel: public Organisme {
class Mouton: public Animal { class Mouton: public Animal {
public: public:
Mouton(void); Mouton(void);
bool carnivore(void);
}; };
class Loups: public Animal { class Loup: public Animal {
public: public:
Loups(void); Loup(void);
bool carnivore(void);
}; };
#endif #endif