Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Exercise: Vehicle System Basic (part 1)

1. Base Class and Basic Polymorphism:


 Vehicle class:
o Create a base class named Vehicle with the following a ributes: make
(string), model (string), and year (int).
o Include a constructor to ini alize these a ributes
o Implement displayInfo() to show the informa on for all vehicle’s a ributes
2. Derived Classes and Func%on Overriding:
 Car class:
o Derive a class Car from Vehicle. Add an a ribute for number_of_doors (int).
o Override displayInfo() to include door informa on.
o Implement getFuelType() to return the car's fuel type.
 Bike class:
o Derive a class Bike from Vehicle, with a boolean a ribute isElectric.
o Override displayInfo() to indicate whether the bike is electric.
o Implement getFuelType() accordingly.
3. Func%on Overloading in Car class:
o Implement method overloading by adding another version of displayInfo()
that accepts a bool detailed parameter. When detailed is true, provide
detailed informa on about the car, including engine type and fuel efficiency.
4. Main Func%on Implementa%on:
o Instan ate objects of Car and Bike, demonstra ng the use of both overriding
(by calling displayInfo() and getFuelType()) and overloading (by calling both
versions of displayInfo() on the Car object).

You might also like