Advertisement
Guest User

RURIKOVI4 4

a guest
May 20th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <iostream>
  3. #include <string>
  4. #include <conio.h>
  5. #include <locale>
  6.  
  7. using namespace std;
  8.  
  9. class Worker // без 15 из 21
  10. {
  11. public:
  12.  
  13. int age;
  14. string name;
  15. float weight;
  16.  
  17.  
  18. void eat(float how_much) // покушать
  19. {
  20. cin >> how_much;
  21. if (how_much > 10)
  22. {
  23. weight += (how_much / 1.5);
  24. age++;
  25. }
  26. else
  27. weight += how_much;
  28.  
  29. walk();
  30. walk();
  31. dance();
  32. dance();
  33. dance();
  34.  
  35. }
  36.  
  37. double get_weight() // показать вес
  38. {
  39. return weight;
  40. }
  41.  
  42. void walk() // гулять +1
  43. {
  44. mood += 1;
  45. }
  46.  
  47. double get_walking() // показать вес
  48. {
  49. return mood;
  50. }
  51.  
  52. void dance() // танцевать +2
  53. {
  54. mood += 2;
  55. }
  56.  
  57. void work() // работать -2
  58. {
  59. mood -= 2;
  60. if (mood < 0)
  61. mood = 0;
  62. }
  63.  
  64. int returnMood() // настроение
  65. {
  66. return mood;
  67. }
  68.  
  69. private:
  70.  
  71.  
  72.  
  73. int mood = 0;
  74.  
  75. };
  76.  
  77. void showWrk1(Worker *wrk1)
  78. {
  79. cout << "Имя: " << wrk1->name << endl; // фамилия
  80. cout << "Возраст: " << wrk1->age << endl; // возраст
  81. double ves = wrk1->get_weight();
  82. cout << "Вес: " << ves << endl;
  83. int mood = wrk1->returnMood();
  84. cout << "Настроение: " << mood << endl << endl;
  85. setlocale(LC_ALL, "rus");
  86. }
  87.  
  88. int main()
  89. {
  90. setlocale(LC_ALL, "rus");
  91.  
  92. Worker *wrk1 = new Worker();
  93. cout << "Введите имя: " << endl;
  94. cin >> wrk1->name;
  95. cout << "Введите возраст: " << endl;
  96. cin >> wrk1->age;
  97. cout << "Введите вес: " << endl;
  98. cin >> wrk1->weight;
  99.  
  100. system("cls");
  101.  
  102. showWrk1(wrk1); // показ (имя , возраст)
  103. cout << "Сколько кг еды вы желаете съесть?" << endl;
  104. wrk1->eat(15);
  105. double ves = wrk1->get_weight();
  106. cout << "*Ну вы и обжора обжора! Ваш вес после еды составил " << ves << "кг" << endl;
  107.  
  108.  
  109.  
  110. for (int i = 0; i < 9; i++) // прогулка х9
  111. wrk1->work();
  112.  
  113. int mood = wrk1->returnMood();
  114. cout << "*Настроение = " << mood;
  115.  
  116. getch();
  117. return 0;
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement