Merge remote-tracking branch 'origin/tortue' into parameter
This commit is contained in:
commit
1ce23256c1
2 changed files with 59 additions and 0 deletions
26
app/include/Tortue.h
Normal file
26
app/include/Tortue.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
//
|
||||
// Created by Victor Le Roch on 20/05/2020.
|
||||
//
|
||||
|
||||
#ifndef BE_TORTUE_H
|
||||
#define BE_TORTUE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
class Tortue{
|
||||
private:
|
||||
std::string nom;
|
||||
int naissance;
|
||||
std::string sexe;
|
||||
public:
|
||||
Tortue(const std::string &nom, const std::string &sexe);
|
||||
|
||||
const std::string &getNom() const;
|
||||
|
||||
int getNaissance() const;
|
||||
int getAge() const;
|
||||
|
||||
const std::string &getSexe() const;
|
||||
};
|
||||
|
||||
#endif //BE_TORTUE_H
|
33
app/src/Tortue.cpp
Normal file
33
app/src/Tortue.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// Created by Victor Le Roch on 20/05/2020.
|
||||
//
|
||||
|
||||
#include "../include/Tortue.h"
|
||||
#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(const string &nom, const string &sexe) : nom(nom), sexe(sexe) {
|
||||
naissance = std::time(nullptr);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in a new issue