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

Create a base class called Vehicle that has the manufacturer\'s name (type strin

ID: 3708838 • Letter: C

Question

Create a base class called Vehicle that has the manufacturer's name (type string),
number of cylinders in the engine (type int), and owner (type Person, given below).


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)
- towing capacity in pounds (type int).

Be sure your classes have a reasonable complement of constructors, accessor, and mutator member functions, an overloaded assignment operator, and a copy constructor. Write a driver program that tests all your member functions.

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 theName);
Person(const Person& theObject);
string get_name() const;
Person& operator=(const Person& rtSide);
friend istream& operator >>(istream& inStream,
Person& personObject);
friend ostream& operator <<(ostream& outStream,
Person& personObject);
private:
string name;
};

here are the header files (Vehicle and Truck)

Explanation / Answer

Note: I will write the code to Truck class also..Thank u

______________

#include <iostream>

using namespace std;

class Person

{

public:

Person();

Person(string theName);

Person(const Person& theObject);

string get_name() const;

Person& operator=(const Person& rtSide);

friend istream& operator >>(istream& inStream,Person& personObject);

friend ostream& operator <<(ostream& outStream,Person& personObject);

private:

string name;

};

Person::Person()

{

}

Person::Person(string theName)

{

this->name=theName;

}

Person::Person(const Person& theObject)

{

name=theObject.name;

}

string Person::get_name() const

{

return name;

}

Person& Person::operator=(const Person& rtSide)

{

name=rtSide.name;

return *this;

}

istream& operator >>(istream& inStream,Person& personObject)

{

cout<<"Enter Person Name :";

getline(inStream,personObject.name);

return inStream;

}

ostream& operator <<(ostream& outStream,Person& personObject)

{

outStream<<"Name :"<<personObject.get_name()<<endl;

return outStream;

}

//================================

// Declaration of Vehicle Class

//================================

class Vehicle

{

public:

Vehicle();

Vehicle(string m, int cyl, Person p);

Vehicle(const Vehicle& theObject);

string getManufacturer() const;

int getCylinders() const;

Person getOwner() const;

void setManufacturer(string maker);

void setCylinders(int cylinders);

void setOwner (Person p);

void output();

// Outputs the data members of the class appropriately labeled

Vehicle& operator=(const Vehicle& rtSide);

private:

string manufacturer;

int numCylinders;

Person owner;

};

Vehicle::Vehicle()

{

}

Vehicle::Vehicle(string m, int cyl, Person p)

{

this->manufacturer=m;

this->numCylinders=cyl;

this->owner=p;

}

Vehicle::Vehicle(const Vehicle& theObject)

{

this->manufacturer=theObject.getManufacturer();

this->numCylinders=theObject.getCylinders();

this->owner=theObject.getOwner();

}

string Vehicle::getManufacturer() const

{

return manufacturer;

}

int Vehicle::getCylinders() const

{

return numCylinders;

}

Person Vehicle::getOwner() const

{

return owner;

}

void Vehicle::setManufacturer(string maker)

{

this->manufacturer=maker;

}

void Vehicle::setCylinders(int cylinders)

{

this->numCylinders=cylinders;

}

void Vehicle::setOwner (Person p)

{

this->owner=p;

}

void Vehicle::output()

{

cout<<"Person Name :"<<owner.get_name()<<endl;

cout<<"Manufacturer :"<<manufacturer<<endl;

cout<<"Number of Cylinders :"<<numCylinders<<endl;

}

// Outputs the data members of the class appropriately labeled

Vehicle& Vehicle::operator=(const Vehicle& rtSide)

{

owner=rtSide.owner;

manufacturer=rtSide.getManufacturer();

numCylinders=rtSide.getCylinders();

return *this;

}

//===============================

// Declaration of Truck Class

//===============================

class Truck : public Vehicle

{

public:

Truck();

Truck(string m, int cyl, Person p, double load, int tow);

Truck(const Truck& theObject);

double getLoadCapacity() const;

int getTowingCapacity() const;

void setLoadCapacity(double newLoad);

void setTowingCapacity(int newTowing);

void output();

// Outputs the data members appropriately labeled.

Truck& operator=(const Truck& rtSide);

private:

double loadCapacity;

int towingCapacity;

};

Truck::Truck()

{

}

Truck::Truck(string m, int cyl, Person p, double load, int tow):Vehicle(m,cyl,p)

{

this->loadCapacity=load;

this->towingCapacity=tow;

}

Truck::Truck(const Truck& theObject)

{

}

double Truck::getLoadCapacity() const

{

}

int Truck::getTowingCapacity() const

{

}

void Truck::setLoadCapacity(double newLoad)

{

}

void Truck::setTowingCapacity(int newTowing)

{

}

void Truck::output()

{

}

// Outputs the data members appropriately labeled.

Truck& Truck::operator=(const Truck& rtSide)

{

}

int main ()

{

return 0;

}

________________