Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include "string"
- using namespace std;
- class vehicle
- {
- public:
- int maxprobeg;
- void set_maxprobeg(int maxp)
- {
- cout << "write max probeg please (kilometers)" << endl;
- cin >> maxp;
- maxprobeg = maxp;
- }
- int get_maxprobeg()
- {
- return maxprobeg;
- }
- int maxbak;
- void set_maxbak(int maxb)
- {
- cout << "write max bak please (liters)" << endl;
- cin >> maxb;
- maxbak = maxb;
- }
- int get_maxbak()
- {
- return maxbak;
- }
- };
- class truck : public vehicle
- {
- private:
- string tru;
- public:
- trailer()
- {
- tru = "Mercedes-Benz Actros 3341 K"
- }
- void show_ch()
- {
- if ((get_maxprobeg() > 0) && (get_maxprobeg() < 1000000) && (get_maxbak() > 0) && (get_maxbak() < 100))
- {
- cout << "max probeg of truck" << tru << " = " << get_maxprobeg() << " km" << " Max bak of truck" << tru << " = " << get_maxbak() << " liters" << endl;
- }
- else
- {
- cout << "add info please" << endl;
- }
- }
- };
- class trailer : public vehicle
- {
- public:
- {
- private:
- string tra;
- public: trailer()
- {
- tra = "Isuzu Elf 2000"
- }
- void show_ch()
- {
- if ((get_maxprobeg() > 0) && (get_maxprobeg() < 1000000) && (get_maxbak() > 0) && (get_maxbak() < 100))
- {
- cout << "max probeg of trailer " << tra << " = " << get_maxprobeg() << " rubles" << " Max bak of trailer " << tra << " = " << get_maxbak() << " years" << endl;
- }
- else
- {
- cout << "add info please" << endl;
- }
- }
- };
- int main()
- {
- truck t1;
- trailer t2;
- int control = 0;
- while (control != 4)
- {
- cout << "press 1 to add characteristics" << endl;
- cout << "press 2 to show information" << endl;
- cout << "press 3 to change information" << endl;
- cout << "press 4 to exit" << endl;
- cin >> control;
- if (control == 1)
- {
- t1.title();
- t1.set_maxprobeg(1);
- t1.set_maxbak(1);
- t2.title();
- t2.set_maxprobeg(1);
- t2.set_maxbak(1);
- }
- if (control == 2)
- {
- t1.show_ch();
- t2.show_ch();
- }
- if (control == 3)
- {
- int menu = 0;
- while (menu != 3)
- {
- cout << "press 1 to change truck characteristics" << endl;
- cout << "press 2 to change trailer characteristics" << endl;
- cout << "press 3 to exit" << endl;
- cin >> menu;
- if (menu == 1)
- {
- t1.title();
- t1.set_maxprobeg(1);
- t1.set_maxbak(1);
- }
- if (menu == 2)
- {
- t2.title();
- t2.set_maxprobeg(1);
- t2.set_maxbak(1);
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement