Lister tortues fonctionne, debut ajouter tortue 2.0
This commit is contained in:
parent
df8d16ef4c
commit
585f568930
3 changed files with 30 additions and 21 deletions
|
@ -16,6 +16,8 @@ private:
|
|||
|
||||
|
||||
public:
|
||||
Tortue();
|
||||
|
||||
Tortue(const std::string &nom, const std::string &sexe);
|
||||
|
||||
const std::string &getNom() const;
|
||||
|
@ -27,7 +29,7 @@ public:
|
|||
void setSexe(const std::string &sexe);
|
||||
|
||||
static int getNbTortue();
|
||||
int getNaissance() const;
|
||||
std::string getNaissance() const;
|
||||
int getAge() const;
|
||||
const std::string &getSexe() const;
|
||||
|
||||
|
|
|
@ -6,32 +6,35 @@
|
|||
#include "../../core_simulation.h"
|
||||
//#include <string>
|
||||
|
||||
const std::string &Tortue::getNom() const {
|
||||
return nom;
|
||||
}
|
||||
|
||||
int Tortue::getNaissance() const {
|
||||
return naissance;
|
||||
}
|
||||
|
||||
const std::string &Tortue::getSexe() const {
|
||||
return sexe;
|
||||
}
|
||||
Tortue::Tortue() {}
|
||||
|
||||
Tortue::Tortue(const string &nom, const string &sexe) : nom(nom), sexe(sexe) {
|
||||
naissance = std::time(nullptr);
|
||||
nbTortue ++;
|
||||
}
|
||||
|
||||
int Tortue::getAge() const {
|
||||
/*int Tortue::getAge() const {
|
||||
int ageSec = std::time(nullptr) - naissance;
|
||||
int ageHour = ageSec/(60*60);
|
||||
int ageDay = ageHour/24;
|
||||
int age = ageDay / 365.25;
|
||||
return age;
|
||||
}
|
||||
}*/
|
||||
int Tortue::nbTortue = 0;
|
||||
|
||||
const std::string &Tortue::getNom() const {
|
||||
return nom;
|
||||
}
|
||||
|
||||
string Tortue::getNaissance() const {
|
||||
return naissance;
|
||||
}
|
||||
|
||||
const std::string &Tortue::getSexe() const {
|
||||
return sexe;
|
||||
}
|
||||
|
||||
int Tortue::getNbTortue() {
|
||||
return nbTortue;
|
||||
}
|
||||
|
@ -57,3 +60,5 @@ void Tortue::setSexe(const string &sexe) {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -43,11 +43,14 @@ void Board::setup(){
|
|||
tortues.push_back(*(new Tortue("Marvin","male")));
|
||||
tortues.push_back(*(new Tortue("Clara","female")));
|
||||
tortues.push_back(*(new Tortue("Camille","non binary")));
|
||||
tortues.push_back(*(new Tortue("Clarisse","danseuse")));
|
||||
|
||||
}
|
||||
|
||||
// la boucle de controle arduino
|
||||
void Board::loop() {
|
||||
char buf[150];
|
||||
char inputBuf[150];
|
||||
static int cpt = 0;
|
||||
static int bascule = 0;
|
||||
int i = 0;
|
||||
|
@ -68,15 +71,10 @@ void Board::loop() {
|
|||
pressure->getValue(),
|
||||
terrarium->getRadState(),
|
||||
terrarium->getTapState(),
|
||||
0);
|
||||
/*strcpy(buf, menu->displayDefault(temperature.getValue(),
|
||||
pressure.getValue(),
|
||||
terrarium.getRadState(),
|
||||
terrarium.getTapState(),
|
||||
0).c_str());*/
|
||||
Tortue::getNbTortue());
|
||||
|
||||
} else if (menu->getMessage().c_str() != NULL){
|
||||
message = menu->getMessage();
|
||||
//strcpy(buf, menu->getMessage().c_str());
|
||||
}
|
||||
|
||||
if (i % 2 == 0) {
|
||||
|
@ -127,7 +125,11 @@ void Board::loop() {
|
|||
}
|
||||
|
||||
if (menu->getId() == 5){
|
||||
Tortue * newTortue;
|
||||
Tortue * newTortue = new Tortue();
|
||||
while (1){
|
||||
bus.requestFrom(2,inputBuf,150);
|
||||
|
||||
}
|
||||
cin >> input;
|
||||
newTortue->setNom(input);
|
||||
tortues.push_back(*newTortue);
|
||||
|
|
Loading…
Reference in a new issue