Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class transport{
- string species;
- public:
- void set(string species){
- this->species = species;
- }
- string get(){
- return species;
- }
- };
- class car : public transport{
- string mark;
- public:
- void set1(string mark){
- this->mark = mark;
- }
- string car_mark(){
- return mark;
- }
- };
- class driver : public car{
- string name;
- int age, experience;
- public:
- void set2(string name, int age, int experience){
- this->name = name;
- this->age = age;
- this->experience = experience;
- }
- string _get0(){
- return name;
- }
- int _get(){
- return experience;
- }
- int _get1(){
- return age;
- }
- };
- class official_driver : public driver{
- public:
- void exp(){
- if(_get() < 10){
- cout << "Не допускается к работе!" << endl;
- }else cout << "Допужен до работы служебным водителем по стажу!" << endl;
- }
- void age(){
- if(_get1() > 50 && _get1() < 18){
- cout << "Не допускается к работе!" << endl;
- }else cout << "Допущен до работы служебным водителем по возрасту!" << endl;
- }
- };
- class taxi_driver : public driver{
- public:
- void exp1(){
- if(_get() < 3){
- cout << "Не допускается к работе!" << endl;
- }else cout << "Допущен для работы в такси по стажу!" << endl;
- }
- void age1(){
- if(_get1() > 50 && _get1() < 18){
- cout << "Не допускается к работе!" << endl;
- }else cout << "Допущен для работы в такси по возрасту!" << endl;
- }
- };
- int main(int argc, const char * argv[]) {
- official_driver od;
- od.set("Легковой автомобиль");
- od.set1("Mercedes");
- od.set2("Иванов Иван Иванович", 30, 10);
- cout << od.get() << endl << od.car_mark() << endl;
- cout << od._get0() << endl;
- cout << "Возраст: " << od._get1() << endl;
- cout << "Стаж вождения: " << od._get() << endl;
- od.exp();
- od.age();
- cout << endl;
- taxi_driver td;
- td.set("Мультивен");
- td.set1("Volkswagen");
- td.set2("Петров Денис Игоревич", 25, 5);
- cout << td.get() << endl << td.car_mark() << endl;
- cout << td._get0() << endl;
- cout << "Возраст: " << td._get1() << endl;
- cout << "Стаж вождения: " << td._get() << endl;
- td.exp1();
- td.age1();
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement