Skip to content

Instantly share code, notes, and snippets.

@grayed
Created March 6, 2024 12:53
Show Gist options
  • Save grayed/35d9c8734e47976b58c4f65823210ac4 to your computer and use it in GitHub Desktop.
Save grayed/35d9c8734e47976b58c4f65823210ac4 to your computer and use it in GitHub Desktop.
Animals with diagnosis
#include <ctime>
#include <iostream>
using namespace std;
class Animal {
string name;
time_t birth_date;
public:
Animal(string name, time_t birth_date) : name(name), birth_date(birth_date) {}
string get_name() const { return name; }
time_t get_birth_date() const { return birth_date; }
int get_age() const { return (time(nullptr) - birth_date) / 60 / 60 / 24 / 365; }
};
class Diagnosis {
Animal &animal;
string disease;
time_t timestamp;
public:
Diagnosis(Animal &a, string dis, time_t ts) : animal(a), disease(dis), timestamp(ts) {}
const Animal& get_animal() const { return animal; }
Animal& get_animal() { return animal; }
string get_disease() const { return disease; }
time_t get_timestamp() const { return timestamp; }
};
/// 1) Создание 3 животных, для каждого - от 0 до 3 диагнозов. Animal cat1("Kitty", 1234567);
/// 2) Ввод имён животных и диагнозов. 3) Ввод даты рождения и её преобразование в birth_date.
int main() {
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment