Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

1 - Objective Enhance the understanding of classes, inheritance, and operator overloading. 2 - Problem Using the given class header file (vehicles.h), you will need

1 - Objective Enhance the understanding of classes, inheritance, and operator overloading.

2 - Problem Using the given class header file (vehicles.h), you will need to implement vehicles.cpp. Do not make any changes to vehicles.h.

From the vehicles class you will need to make two child classes, watercraft and automobile. These should also be implemented using separate header and cpp files (e.g., watercraft.h, watercraft.cpp, automobile.h, automobile.cpp)

Your watercraft class must have the following:

- Two additional attributes, hull and manufacture, in the private section. They should be of type string

- A default constructor that takes no arguments and sets the attributes to:

- engine to "Minn Kota Max 70"

- weight to 1860

- hull to "V - Hull"

- seats to 12

- manufacture to "Sea Ark Boats"

- Member functions to access and modify these attributes (i.e., seats, engine, hull, etc. must all be able to be changed by calling a member function)

- Print to file should take a string as an argument and be a member function. This should be the name of the file to be printed to, your default output file should be out.txt

- A static int counter that will be used to count how many watercraft objects were created.

- An operator overloaded function that is a member function of the class for the = sign that will allow you to copy the information from one watercraft object to another.

Your automobile class must have the following:

- Two additional attributes of type string, make and model, and one additional attribute of type int: wheels. All of them should be defined in the private section.

- A default constructor that takes no arguments and sets the attributes to:

- engine to "V6"

- wheels to 4

- weight to 4079

- seats to 2

- make to "Toytoa"

- model to "Solara"

- A constructor that takes two string arguments that correspond to make and model in that order and one integer argument setting the number of wheels.

- Member functions to access and modify the attributes (seats, engine, wheels etc. must all be able to be changed by calling a member function)

- Print to file should take a string as an argument and be a member function. This should be the name of the file to be printed to, your default output file should be out.txt

- A static int counter that will be used to count how many automobile objects were created.

- An operator overload function that is a member function for the class for the = sign that will allow you to copy the information from one automobile object to another.

In your main.cpp you will need to create 3 objects of type watercraft, and 4 of type automobile. The first two watercraft objects will be created with the default constructor. Two objects of the type automobile will be created with the default constructor. The third automobile object should be created with the constructor that accepts three arguments, make, model, and wheels. Wheels should have a default value of 4 set if it is not provided in the constructor. Please refer to the example output files for values to use for make and model.

Watercraft object 3 and automobile object 4 should use the overloaded = to assign the information from the second object of each type. (ie boat3 = boat2 and car4 = car2)

The first object of each type contains the information for the default constructor. The second object of each has been modified via the mutators, and the third automobile has been created with the constructor that takes arguments for the make and model attributes.

The last two objects in the file are the result of using the overloaded = and should be identical to earlier objects.

You will also need to use three static member counters to keep track of how many objects are made. The last three lines of the output file reflect this. HINT: The static member variables need to be initialized outside of the main function before any objects are created.

Sample Output:

image text in transcribed

Watercraft: Engine: Minn Kota Max 70 Weight: 1860lbs Seats: 12 Hull: v - Hull Manufacturer: Sea Ark Boats Watercraft: Engine: Yamaha 115 HP Weight: 5200lbs Seats: 10 Hull: Fiberglass Manufacturer: Sea Ark Boats Automobile: Engine: V6 Wheels: 4 Weight: 4079lbs Seats: 2 Make: Toytoa Model: Solara Automobile: Engine: 3A90 I3 Wheels: 4 Weight: 20721bs Seats: 5 Make: Mirage Model: Mitsubishi Automobile: Engine: V6 Wheels: 4 Weight: 4079lbs Seats: 2 Make: Honda Model: Accord Watercraft: Engine: Minn Kota Max 70 Weight: 1860lbs Seats: 12 Hull: v - Hull Manufacturer: Sea Ark Boats Watercraft: Engine: Yamaha 115 HP Weight: 5200lbs Seats: 10 Hull: Fiberglass Manufacturer: Sea Ark Boats Automobile: Engine: V6 Wheels: 4 Weight: 4079lbs Seats: 2 Make: Toytoa Model: Solara Automobile: Engine: 3A90 I3 Wheels: 4 Weight: 20721bs Seats: 5 Make: Mirage Model: Mitsubishi Automobile: Engine: V6 Wheels: 4 Weight: 4079lbs Seats: 2 Make: Honda Model: Accord

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions