Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do in C++. Ship, CruiseShip, and CargoShip Classes Design an abstract class Ship that has the following members: A member variable for the name of

Do in C++.

Ship, CruiseShip, and CargoShip Classes

Design an abstract class Ship that has the following members:

A member variable for the name of the ship (a string)

A member variable for the year that the ship was built (a string)

A constructor and appropriate accessors and mutators

A pure virtual print function.

Design a CruiseShip class that is derived from the Ship class. The CruiseShip class should have the following members:

A member variable for the maximum number of passengers (an unsigned int)

A constructor and appropriate accessors and mutators

A print function that overrides the print function in the base class. The CruiseShip classs print function should display the ships name, the year it was built, and the maximum number of passengers.

Design a CargoShip class that is derived from the Ship class. The CargoShip class should have the following members:

A member variable for the cargo capacity in tonnage (an unsigned int).

A constructor and appropriate accessors and mutators

A print function that overrides the print function in the base class. The CargoShip classs print function should display the ships name, the year it was build, and the ships cargo capacity.

You do not have to create header files for the classes, but you can if you want to. You can inline as much (or little) of the code as you want.

Demonstrate the classes in a program that has an array of Ship pointers. The array elements should be initialized with the addresses of dynamically allocated CruiseShip, and CargoShip objects. You can read in the ship names, years, and other information from the user or you can just hard code values in your program.

Use a loop to iterate through all of the Ship pointers and call the print function for each.

Update some of the Ship values via their accessors. If you want to update the number of passengers for a CruiseShip you will need to dynamically cast it to type CruiseShip to make this change.

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago