Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <time.h>
- using namespace std;
- class Cat
- {
- private:
- int CatAge = 0;
- int CatFood = 0;
- public:
- const void Die();
- const int GetAge();
- void SetAge(int age);
- };
- const void Cat::Die()
- {
- printf("Кот сдох. Прожил: %d\n", GetAge());
- }
- const int Cat::GetAge()
- {
- return CatAge;
- }
- void Cat::SetAge(int age)
- {
- CatAge = age;
- }
- int main()
- {
- setlocale(LC_ALL, "rus");
- srand(time(NULL));
- unsigned int start_t = time(NULL);
- unsigned int t = 0;
- Cat po;
- unsigned short int ticks = rand() % 60;
- printf("Кот должен прожить: %d\n", ticks);
- while(t < ticks)
- {
- t = time(NULL) - start_t;
- po.SetAge(t);
- };
- po.Die();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement