Design a Ship class that has the following members A member
Design a Ship class 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 virtual print function that displays the ship’s name and the year it was built.
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 int )
• A constructor and appropriate accessors and mutators
• A print function that overrides the print function in the base class. The CruiseShip class’s print function should display only the ship’s name 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 int ).
• A constructor and appropriate accessors and mutators.
• A print function that overrides the print function in the base class. The CargoShip class’s print function should display only the ship’s name and the ship’s cargo capacity.
After you have created these classes, create a driver program that defines an array pointers to your abstract base class Ship. It should present a menu to allow the user to enter a Cruise Ship or a Cargo Ship. When the user selects cruise ship, it should prompt them for the name, year built, and the number of passengers. When the user selects cargo ship, it should prompt them ffor the name, year built, and the maxium cargo load (in tons). Each selection should create an object that can be stored into your array of pointers. When the program exits, it should display the history of the session which includes each of the objects the user created which will be a combination of cruise ships and cargo ships. An example output is shown here:
Menu
1. Cruise Ship
2. Cargo Ship
3. Quit
Please make your selection: 2
Please enter the name of the ship: Big Bertha
Please enter the year the ship was built: 1975
Please enter the capacity (tons): 50000
Menu
1. Cruise Ship
2. Cargo Ship
3. Quit
Please make your selection: 1
Please enter the name of the ship: Disney Magic
Please enter the year the ship was built: 1998
Please enter the capacity (passengers): 2400
Menu
1. Cruise Ship
2. Cargo Ship
3. Quit
Please make your selection: 3
The history of your session is
Selected Cargo Ship
Name: Big Bertha
Year: 1975
Capacity (tons): 50000
Selected Cruise Ship
Name: Disney Magic
Year: 1998
Capacity (passengers): 2400
Solution
Ship.h
Ship.cpp
Main function:
CruiseShip.h
CruiseShip.cpp

