Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.06 KB | None | 0 0
  1. #include <iostream>
  2. #include "string"
  3. using namespace std;
  4.  
  5. class vehicle
  6. {
  7. public:
  8. int maxprobeg;
  9. void set_maxprobeg(int maxp)
  10. {
  11. cout << "write max probeg please (kilometers)" << endl;
  12. cin >> maxp;
  13. maxprobeg = maxp;
  14. }
  15. int get_maxprobeg()
  16. {
  17. return maxprobeg;
  18. }
  19. int maxbak;
  20. void set_maxbak(int maxb)
  21. {
  22. cout << "write max bak please (liters)" << endl;
  23. cin >> maxb;
  24. maxbak = maxb;
  25. }
  26. int get_maxbak()
  27. {
  28. return maxbak;
  29. }
  30. };
  31. class truck : public vehicle
  32. {
  33.  
  34. private:
  35.  
  36. string tru;
  37.  
  38. public:
  39.  
  40. trailer()
  41.  
  42. {
  43.  
  44. tru = "Mercedes-Benz Actros 3341 K"
  45.  
  46. }
  47. void show_ch()
  48. {
  49. if ((get_maxprobeg() > 0) && (get_maxprobeg() < 1000000) && (get_maxbak() > 0) && (get_maxbak() < 100))
  50. {
  51. cout << "max probeg of truck" << tru << " = " << get_maxprobeg() << " km" << " Max bak of truck" << tru << " = " << get_maxbak() << " liters" << endl;
  52. }
  53. else
  54. {
  55. cout << "add info please" << endl;
  56. }
  57. }
  58. };
  59. class trailer : public vehicle
  60. {
  61. public:
  62. {
  63.  
  64. private:
  65.  
  66. string tra;
  67.  
  68. public: trailer()
  69. {
  70. tra = "Isuzu Elf 2000"
  71. }
  72. void show_ch()
  73. {
  74. if ((get_maxprobeg() > 0) && (get_maxprobeg() < 1000000) && (get_maxbak() > 0) && (get_maxbak() < 100))
  75. {
  76. cout << "max probeg of trailer " << tra << " = " << get_maxprobeg() << " rubles" << " Max bak of trailer " << tra << " = " << get_maxbak() << " years" << endl;
  77. }
  78. else
  79. {
  80. cout << "add info please" << endl;
  81. }
  82. }
  83. };
  84. int main()
  85. {
  86. truck t1;
  87. trailer t2;
  88. int control = 0;
  89. while (control != 4)
  90. {
  91. cout << "press 1 to add characteristics" << endl;
  92. cout << "press 2 to show information" << endl;
  93. cout << "press 3 to change information" << endl;
  94. cout << "press 4 to exit" << endl;
  95. cin >> control;
  96. if (control == 1)
  97. {
  98. t1.title();
  99. t1.set_maxprobeg(1);
  100. t1.set_maxbak(1);
  101. t2.title();
  102. t2.set_maxprobeg(1);
  103. t2.set_maxbak(1);
  104. }
  105. if (control == 2)
  106. {
  107. t1.show_ch();
  108. t2.show_ch();
  109. }
  110. if (control == 3)
  111. {
  112. int menu = 0;
  113. while (menu != 3)
  114. {
  115. cout << "press 1 to change truck characteristics" << endl;
  116. cout << "press 2 to change trailer characteristics" << endl;
  117. cout << "press 3 to exit" << endl;
  118. cin >> menu;
  119. if (menu == 1)
  120. {
  121. t1.title();
  122. t1.set_maxprobeg(1);
  123. t1.set_maxbak(1);
  124. }
  125. if (menu == 2)
  126. {
  127. t2.title();
  128. t2.set_maxprobeg(1);
  129. t2.set_maxbak(1);
  130. }
  131. }
  132. }
  133. }
  134. return 0;
  135. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement