Jommiey

Lektion3_2

Nov 19th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.30 KB | None | 0 0
  1. class Vehicle
  2. {
  3. public:
  4.   Vehicle(int number_of_wheels = 0, int max_speed = 0)
  5.     : number_of_wheels{number_of_wheels}, max_speed{max_speed}
  6.     {
  7.       if (number_of_wheels > 6)
  8.       {
  9.         max_speed{100};
  10.       }
  11.     }
  12.  
  13.   int get_number_of_wheels() const;
  14.   int get_max_speed() const;
  15.  
  16.   Location& get_start_point() const;
  17.   Location& get_destination() const;
  18.  
  19. protected:
  20.   int number_of_wheels;
  21.   int max_speed;
  22.   Location start_point; //made-up class Location
  23.   Location destination; //made-up class Location
  24. };
  25.  
  26. class Passenger_Vehicle: public Vehicle
  27. {
  28. public:
  29.   Passenger_Vehicle(int wheels = 0, int speed = 0,
  30.                     int passengers = 0, int doors = 0)
  31.    : Vehicle{wheels, speed},
  32.      numbers_of_passengers{passengers}, number_of_doors{doors}
  33.    {
  34.    }
  35.  
  36.   int get_number_of_passengers() const;
  37.   int get_number_of_doors() const;
  38.  
  39. private:
  40.   int number_of_passengers;
  41.   int number_of_doors;
  42. };
  43.  
  44.  
  45. class Freight_Vehicle: public Vehicle
  46. {
  47. public:
  48.   Freight_Vehicle(int wheels = 0, int speed = 0,
  49.                   int payload = 0)
  50.     : Vehicle{wheels, speed}, max_payload{payload}
  51.     {
  52.     }
  53.  
  54.   int get_max_payload() const;
  55.   void load_freight_vehicle();
  56.   Load& unload_freight_vehicle(); //made-up class Load
  57.  
  58. private:
  59.   int max_payload;
  60. };
Add Comment
Please, Sign In to add comment