Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- #include <string>
- #include <conio.h>
- #include <locale>
- using namespace std;
- class Worker // без 15 из 21
- {
- public:
- int age;
- string name;
- float weight;
- void eat(float how_much) // покушать
- {
- cin >> how_much;
- if (how_much > 10)
- {
- weight += (how_much / 1.5);
- age++;
- }
- else
- weight += how_much;
- walk();
- walk();
- dance();
- dance();
- dance();
- }
- double get_weight() // показать вес
- {
- return weight;
- }
- void walk() // гулять +1
- {
- mood += 1;
- }
- double get_walking() // показать вес
- {
- return mood;
- }
- void dance() // танцевать +2
- {
- mood += 2;
- }
- void work() // работать -2
- {
- mood -= 2;
- if (mood < 0)
- mood = 0;
- }
- int returnMood() // настроение
- {
- return mood;
- }
- private:
- int mood = 0;
- };
- void showWrk1(Worker *wrk1)
- {
- cout << "Имя: " << wrk1->name << endl; // фамилия
- cout << "Возраст: " << wrk1->age << endl; // возраст
- double ves = wrk1->get_weight();
- cout << "Вес: " << ves << endl;
- int mood = wrk1->returnMood();
- cout << "Настроение: " << mood << endl << endl;
- setlocale(LC_ALL, "rus");
- }
- int main()
- {
- setlocale(LC_ALL, "rus");
- Worker *wrk1 = new Worker();
- cout << "Введите имя: " << endl;
- cin >> wrk1->name;
- cout << "Введите возраст: " << endl;
- cin >> wrk1->age;
- cout << "Введите вес: " << endl;
- cin >> wrk1->weight;
- system("cls");
- showWrk1(wrk1); // показ (имя , возраст)
- cout << "Сколько кг еды вы желаете съесть?" << endl;
- wrk1->eat(15);
- double ves = wrk1->get_weight();
- cout << "*Ну вы и обжора обжора! Ваш вес после еды составил " << ves << "кг" << endl;
- for (int i = 0; i < 9; i++) // прогулка х9
- wrk1->work();
- int mood = wrk1->returnMood();
- cout << "*Настроение = " << mood;
- getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement