summaryrefslogtreecommitdiff
path: root/sem_3/Programm/TP2/ex1/jeudelaviemine/cell.cpp
blob: 9c17eb7a97ff635e874d0026ee78d52d52727eea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "cell.h"
#include<iostream>

void cell::setColor(color nouvelle){
  couleur = nouvelle;
}

color cell::getColor(){
  return couleur;
}

void cell::setVivante(bool a) {
  statut = a;
}
int cell::getX () {
  return x;
}

int cell::getY () {
  return y;
}
bool cell::getVivante() {
  return statut;
}
void cell::printcell () {
  std::cout << "La cellule ( à l'adresse mémoire " <<  this << " ) = {" << (statut ? "vivante" : "morte")<<", " << x << "x"<<y <<"}"<<std::endl;
}

bool cell::estvoisineenVie (cell &cellule) {
  if ( cellule.x == x + 1 || cellule.y == y + 1 || cellule.x == x - 1 || cellule.y == y - 1 ) {
    if (cellule.statut) {
      return true;
    }
  }

  return false;
}

cell::cell ( int a, int b, bool c) {
  x = a;
  y = b;
  statut = c;
}