Exercise: Vehicle Management System

Implement the vehicle management system using OOP concept.

We'll cover the following

Problem statement

Let's suppose a company needs a vehicle management system to manage different types of vehicles. Each vehicle has common attributes and behaviors, but certain types of vehicles have specific behaviors. Implement the following classes and methods:

  1. Vehicle (base class):

    1. Attributes: make , model

    2. Methods: display_info(), prints the make and model of the vehicle.

  2. Car (derived class):

    1. Inherits from: Vehicle

    2. Additional attributes: num_doors

    3. Overridden method: display_info(), prints the make, model, and number of doors.

  3. Motorcycle (derived class):

    1. Inherits from: Vehicle

    2. Additional attributes: type_of_handlebars

    3. Overridden method: display_info(), prints the make, model, and type of handlebars.

  4. Truck (Derived Class):

    1. Inherits from: Vehicle

    2. Additional attributes: payload_capacity

    3. Overridden method: display_info(), prints the make, model, and payload capacity.

The main function is already given. You need to create the classes, attributes, and methods based on the main function.

Coding challenge

Take some time to think about how many classes are created and identify their attributes and functions in the context of a vehicle management system. Ensure you account for all possible edge cases, such as invalid vehicle IDs or negative mileage. Pay attention to the relationships between classes, such as inheritance and composition. If you find yourself struggling, you can look at the solution review in the next lesson for guidance.

Good luck!

Get hands-on with 1200+ tech skills courses.