diff --git a/app/include/Tortue.h b/app/include/Tortue.h index f4bafd9..adc8b7c 100644 --- a/app/include/Tortue.h +++ b/app/include/Tortue.h @@ -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; diff --git a/app/src/Tortue.cpp b/app/src/Tortue.cpp index d00839c..bac34e5 100644 --- a/app/src/Tortue.cpp +++ b/app/src/Tortue.cpp @@ -6,32 +6,35 @@ #include "../../core_simulation.h" //#include -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) { } + + diff --git a/sketch_ino.cpp b/sketch_ino.cpp index 671f0d7..d53209e 100644 --- a/sketch_ino.cpp +++ b/sketch_ino.cpp @@ -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);