Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Sample Question 5.2: Consider the following objects and their properties: Car: f

ID: 3834725 • Letter: S

Question

Sample Question 5.2: Consider the following objects and their properties:

Car: fuel capacity, serial number, passenger capacity, net weight, license plate Boat: fuel capacity, serial number, passenger capacity, net weight, draft
We want to use inheritance to implement the above given objects. Define a third class which can be the superclass. Provide a list of fields that will be included in each of the classes.
Sample Question 5.2: Consider the following objects and their properties:

Car: fuel capacity, serial number, passenger capacity, net weight, license plate Boat: fuel capacity, serial number, passenger capacity, net weight, draft
We want to use inheritance to implement the above given objects. Define a third class which can be the superclass. Provide a list of fields that will be included in each of the classes.
Sample Question 5.2: Consider the following objects and their properties:


We want to use inheritance to implement the above given objects. Define a third class which can be the superclass. Provide a list of fields that will be included in each of the classes.

Explanation / Answer

Both the objects have a some common properties hence the common properties are written in a superclass and you dont have to define those properties in both the objects seperately.

So the superclass will have the common properties. And the two objects will have their unique properties which is draft in case of boat object and license plate in car object.

Below is the contents of all the classes:

//This is your superclass which will contain common fields
class superclass {

public :
int fuel_capacity;
int serial_no;
int passenger_capacity;
int net_weight;
};

//Car class
class car : public superclass
{
public:
int license_plate;
};

//Boat class
class boat : public superclass
{
public:
int draft;
};

Hope you found it helpful. Thanks.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote