We want to store the information of different vehicles. Create a class named Vehicle with two data member named mileage and price. Create its two subclasses Car with data members to store ownership cost, warranty (by years), seating capacity and fuel type (diesel or petrol). Bike with data members to store the number of cylinders, number of gears, cooling type(air, liquid or oil), wheel type(alloys or spokes) and fuel tank size(in inches) Make another two subclasses Tata and Maruti of Car, each having a data member to store the model type. Next, make two subclasses Hero and TVS of bike , each having a data member to store the make-type. Now, store and print the information of an Tata and a Maruti car (i.e. model type, ownership cost, warranty, seating capacity, fuel type, mileage and price.) Do the same for a Hero and a TVS bike.
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
We want to store the information of different vehicles. Create a class named Vehicle
with two data member named mileage and price. Create its two subclasses
Car with data members to store ownership cost, warranty (by years), seating capacity
and fuel type (diesel or petrol).
Bike with data members to store the number of cylinders, number of gears, cooling
type(air, liquid or oil), wheel type(alloys or spokes) and fuel tank size(in inches)
Make another two subclasses Tata and Maruti of Car, each having a data member to
store the model type.
Next, make two subclasses Hero and TVS of bike , each having a data member to store
the make-type.
Now, store and print the information of an Tata and a Maruti car (i.e. model type,
ownership cost, warranty, seating capacity, fuel type, mileage and price.)
Do the same for a Hero and a TVS bike.
Step by step
Solved in 2 steps with 1 images