比較提交
3 個提交
f9b655d9ce
...
1ce23256c1
作者 | SHA1 | 日期 | |
---|---|---|---|
1ce23256c1 | |||
|
1bdf07a941 | ||
|
a108668d6d |
共有 2 個檔案被更改,包括 59 行新增 和 0 行删除
26
app/include/Tortue.h
一般檔案
26
app/include/Tortue.h
一般檔案
|
@ -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
一般檔案
33
app/src/Tortue.cpp
一般檔案
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
載入中…
新增問題並參考