Question: 10.8 Program: Vehicles (C++) Create a base class called Vehicle that has as properties: the manufacturers name (type string), number of cylinders in the engine

10.8 Program: Vehicles (C++)

Create a base class called Vehicle that has as properties:

the manufacturers name (type string),

number of cylinders in the engine (type int), and

owner (type Person, given below).

and methods:

getters and setters for all properties (getManufacturer, getOwner, getCylinders, setManufacturer, setOwner, getCylinders)

overloaded << operator

default constructor - initialize the manufacture's name to "none", number of cylinders to 4, and the owner to a default Person

parameterized constructor - passing a string owner name, string manufacturer name, and int cylinders. Use a constructor initialization list to initialize person object with the passed name like so:

Vehicle::Vehicle(string the_name,string man_name, int num_cyl):owner(the_name) 

Then create a class called Truck that is derived from Vehicle and has additional properties:

the load capacity in tons (type double since it may contain a fractional part) and

towing capacity in pounds (type int).

and methods:

getters and setters for all properties (getLoad, getTowing, setLoad, setTowing)

overloaded << operator

default constructor initializing properties to 0

parameterized constructor receiving 5 values.

The signature for the headers for the default and parameterized constructors need to following the below pattern:

Truck::Truck(): Vehicle("none","Ford",4) Truck::Truck(string owner, string manufact, int numCyl, double load, double towing):Vehicle(owner,manufact,numCyl) 

The definition of the class Person is below. The implementation of the class is part of this programming project.

class Person { public: Person(); Person(string the_name); string getName() const; void setName(string name); friend ostream& operator <<(ostream& out_stream, const Person& person_object); private: string name; }; 

In main(), based on user input for the needed values, create an instance of a Car and a Truck object and test all your member functions as shown:

Using the parameterized constructor, Create a Vehicle object

Output the object using the overloaded << operator

Change each attribute of the object using appropriate setters

Output the object again to show the changes

Repeat the same process with a Truck object.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!