Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Vehicle
- {
- public:
- Vehicle(int number_of_wheels = 0, int max_speed = 0)
- : number_of_wheels{number_of_wheels}, max_speed{max_speed}
- {
- if (number_of_wheels > 6)
- {
- max_speed{100};
- }
- }
- int get_number_of_wheels() const;
- int get_max_speed() const;
- Location& get_start_point() const;
- Location& get_destination() const;
- virtual std::string describe_vehicle() = 0;
- protected:
- int number_of_wheels;
- int max_speed;
- Location start_point; //made-up class Location
- Location destination; //made-up class Location
- };
- class Passenger_Vehicle: public Vehicle
- {
- public:
- Passenger_Vehicle(int wheels = 0, int speed = 0,
- int passengers = 0, int doors = 0)
- : Vehicle{wheels, speed},
- numbers_of_passengers{passengers}, number_of_doors{doors}
- {
- }
- int get_number_of_passengers() const;
- int get_number_of_doors() const;
- std::string describe_vehicle() override
- {
- std::string out{};
- out = out + "Number of wheels: " + std::to_string(number_of_wheels) + "\n";
- out = out + "Top speed: " + std::to_string(max_speed) + "\n";
- out = out + "Number of passengers: " + std::to_string(number_of_passengers);
- out += "\n";
- out = out + "Number of doors: " + std::to_string(number_of_doors) + "\n";
- return out;
- }
- private:
- int number_of_passengers;
- int number_of_doors;
- };
- class Freight_Vehicle: public Vehicle
- {
- public:
- Freight_Vehicle(int wheels = 0, int speed = 0,
- int payload = 0)
- : Vehicle{wheels, speed}, max_payload{payload}
- {
- }
- int get_max_payload() const;
- void load_freight_vehicle();
- Load& unload_freight_vehicle(); //made-up class Load
- std::string describe_vehicle() override
- {
- std::string out{};
- out = out + "Number of wheels: " std::to_string(number_of_wheels) + "\n";
- out = out + "Top speed: " std::to_string(max_speed) + "\n";
- out = out + "Max payload: " std::to_string(max_payload) + "\n";
- return out;
- }
- private:
- int max_payload;
- };
Advertisement
Add Comment
Please, Sign In to add comment