Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- class Car
- {
- protected:
- string NameOfCar;
- void friend setName(string NameOfCar)
- {
- cout << "Enter name of car:";
- cout << "Enter name of suspension:" << endl; //TODO
- }
- void GetName()
- { //TODO
- }
- virtual void ToStartTheCar()
- {
- cout << "Engine is running" << endl;
- }
- virtual void SwitchGears()
- {
- cout << "The clutch is squeezed out!" << endl;
- }
- };
- class SuspensionBracket : private Car
- {
- protected:
- string NameOfSuspensition;
- };
- class Transmition: public Car
- {
- protected:
- string NameOfTransmition;
- int CountOfGears;
- int NumberOfGear=0;
- int t;
- void SwitchGears() override
- {
- cout << " 1. Shift gear up" << endl << " 2.Shift gear down" << endl << "3. Shift into reverse" << endl;
- cin >> t;
- if (t == 1)
- {
- cout << "The transmission switched" << NumberOfGear++ << endl;
- }
- else if (t == 2)
- {
- cout << "The transmission switched" << NumberOfGear-- << endl;
- }
- else if (t == 3)
- {
- cout << "Reverse gear is engaged" << endl;
- NumberOfGear = 0;
- }
- else
- {
- cout << "Try again" << endl;
- cin >> t;
- }
- }
- };
- class Engine: public Car
- {
- protected:
- int ValueOfEngine;
- int CountOfCylinder;
- int y;
- void ToStartTheCar() override
- {
- cout << " 1. To add engine speed" << endl << " 2. reduce the engine speed" << endl;
- cin >> y;
- if (y == 1)
- {
- cout << "Engine speed added, it's time to shift up gear" << endl;
- return;
- }
- else if (y == 2)
- {
- cout << "Engine speed was reduced, it's time to shift down gear" << endl;
- return;
- }
- else
- {
- cout << "Try again!" << endl;
- cin >> y;
- }
- }
- };
- class Wheel: public Transmition,private Engine
- {
- protected:
- int SizeOfWheel;
- void SwitchGears() override
- {
- if (NumberOfGear >= 0 && NumberOfGear <= 3)
- {
- cout << "Step on the gas son" << endl;
- }
- else if (NumberOfGear>3&&NumberOfGear<=5)
- {
- cout << "You're driver!" << endl;
- }
- else if (NumberOfGear>=6)
- {
- cout << "Don't rush brother, mothers need us" << endl;
- }
- }
- };
- void menu()
- {
- bool f = false;
- int k;
- do
- {
- cout<<" 1. Enter cars "<<endl<<" 2. View cars"<<endl<<" 3. Exit"<< endl;
- cin >> k;
- switch (k)
- {
- case 1:
- break;
- case 2:
- break;
- case 3:
- f = true;
- break;
- default:
- cout << "Try again!" << endl;
- break;
- }
- } while (!f);
- }
- int main()
- {
- menu();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement