From 9fe033ea88c2f705ec18c232873d056e0c229d72 Mon Sep 17 00:00:00 2001 From: Gaspard Coulet Date: Wed, 28 Apr 2021 23:05:53 +0200 Subject: Initial commit --- sem_3/Programm/jeu_de_la_vie/cellule.cpp | 95 ++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 sem_3/Programm/jeu_de_la_vie/cellule.cpp (limited to 'sem_3/Programm/jeu_de_la_vie/cellule.cpp') diff --git a/sem_3/Programm/jeu_de_la_vie/cellule.cpp b/sem_3/Programm/jeu_de_la_vie/cellule.cpp new file mode 100644 index 0000000..7611e7a --- /dev/null +++ b/sem_3/Programm/jeu_de_la_vie/cellule.cpp @@ -0,0 +1,95 @@ +#include "cellule.h" +#include +#include +using namespace std; + +Cellule::Cellule(): age(0), x(0), y(0), couleur(NOIR) { +} + +Cellule::Cellule(bool etat, unsigned int x, unsigned int y): + age(etat ? 1 : 0), x(x), y(y), couleur(etat ? BLEU : NOIR) { +} + +bool Cellule::getVivante() const { + return age; +} + +unsigned int Cellule::getX() const { + return x; +} + +unsigned int Cellule::getY() const { + return y; +} + +Cellule::Couleur Cellule::getCouleur() const { + return couleur; +} + +// Accesseurs en écriture +void Cellule::setX(unsigned int x) { + this->x = x; +} + +void Cellule::setY(unsigned int y) { + this->y = y; +} + +bool Cellule::estVoisine(const Cellule &c) const { + return age && + ((x - c.x) * (x - c.x) + (y - c.y) * (y - c.y) <= 2); +} + +void Cellule::print() const { + std::cout<<"("< "<