Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

L

Lab Submission

10.8.1: Program: Vehicles

Instructions

Deliverables

Truck.cpp

,

Truck.h

,

Vehicle.h

,

main.cpp

,

Person.h

,

Vehicle.cpp

and

Person.cpp

We will expect the above file(s) to be submitted

Compile command

g++ Truck.cpp main.cpp Vehicle.cpp Person.cpp -Wall -o a.out

We will use this command to compile your code

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago