AlexandrTalchuk

Untitled

Dec 6th, 2020
29
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4.  
  5. class Car
  6. {
  7. protected:
  8. string NameOfCar;
  9.  
  10. void friend setName(string NameOfCar)
  11. {
  12. cout << "Enter name of car:";
  13.  
  14. cout << "Enter name of suspension:" << endl; //TODO
  15.  
  16.  
  17. }
  18.  
  19. void GetName()
  20. { //TODO
  21.  
  22. }
  23.  
  24. virtual void ToStartTheCar()
  25. {
  26. cout << "Engine is running" << endl;
  27. }
  28.  
  29. virtual void SwitchGears()
  30. {
  31. cout << "The clutch is squeezed out!" << endl;
  32. }
  33. };
  34.  
  35. class SuspensionBracket : private Car
  36. {
  37. protected:
  38. string NameOfSuspensition;
  39. };
  40.  
  41. class Transmition: public Car
  42. {
  43. protected:
  44. string NameOfTransmition;
  45. int CountOfGears;
  46. int NumberOfGear=0;
  47. int t;
  48.  
  49. void SwitchGears() override
  50. {
  51. cout << " 1. Shift gear up" << endl << " 2.Shift gear down" << endl << "3. Shift into reverse" << endl;
  52. cin >> t;
  53. if (t == 1)
  54. {
  55. cout << "The transmission switched" << NumberOfGear++ << endl;
  56. }
  57. else if (t == 2)
  58. {
  59. cout << "The transmission switched" << NumberOfGear-- << endl;
  60. }
  61. else if (t == 3)
  62. {
  63. cout << "Reverse gear is engaged" << endl;
  64. NumberOfGear = 0;
  65. }
  66. else
  67. {
  68. cout << "Try again" << endl;
  69. cin >> t;
  70. }
  71.  
  72.  
  73. }
  74. };
  75.  
  76. class Engine: public Car
  77. {
  78. protected:
  79. int ValueOfEngine;
  80. int CountOfCylinder;
  81. int y;
  82.  
  83. void ToStartTheCar() override
  84. {
  85. cout << " 1. To add engine speed" << endl << " 2. reduce the engine speed" << endl;
  86. cin >> y;
  87. if (y == 1)
  88. {
  89. cout << "Engine speed added, it's time to shift up gear" << endl;
  90. return;
  91. }
  92. else if (y == 2)
  93. {
  94. cout << "Engine speed was reduced, it's time to shift down gear" << endl;
  95. return;
  96. }
  97. else
  98. {
  99. cout << "Try again!" << endl;
  100. cin >> y;
  101. }
  102. }
  103. };
  104.  
  105. class Wheel: public Transmition,private Engine
  106. {
  107. protected:
  108. int SizeOfWheel;
  109. void SwitchGears() override
  110. {
  111. if (NumberOfGear >= 0 && NumberOfGear <= 3)
  112. {
  113. cout << "Step on the gas son" << endl;
  114. }
  115. else if (NumberOfGear>3&&NumberOfGear<=5)
  116. {
  117. cout << "You're driver!" << endl;
  118. }
  119. else if (NumberOfGear>=6)
  120. {
  121. cout << "Don't rush brother, mothers need us" << endl;
  122. }
  123.  
  124. }
  125. };
  126.  
  127. void menu()
  128. {
  129. bool f = false;
  130. int k;
  131. do
  132. {
  133. cout<<" 1. Enter cars "<<endl<<" 2. View cars"<<endl<<" 3. Exit"<< endl;
  134. cin >> k;
  135. switch (k)
  136. {
  137. case 1:
  138. break;
  139. case 2:
  140. break;
  141. case 3:
  142. f = true;
  143. break;
  144. default:
  145. cout << "Try again!" << endl;
  146. break;
  147. }
  148. } while (!f);
  149. }
  150.  
  151. int main()
  152. {
  153. menu();
  154. }
  155.  
RAW Paste Data