Question: Please help me solve in javaProgram # 5 Instructions Create a Ship class that has the following members: A field for the name of the
Please help me solve in javaProgram # Instructions
Create a Ship class that has the following members:
A field for the name of the ship name String data type
A field for the year that the shop was built year String data type
A constructor and appropriate gets accessors and sets mutators
A method called toString that displays the ship's name and the year it was built
Create a CruiseShip class that extends the Ship class. The CruiseShip class should have the
following members:
A field for the maximum number of passengers passengers Integer data type
A constructor and appropriate gets accessors and sets mutators
A method that overrides the toString method in the base class. The CruiseShip class's
toString method should display only the ship's name and the maximum number of
passengers the ship can carry.
Create a CargoShip class that extends the Ship class. The CargoShip class should have the
following members:
A field for the cargo capacity in tons tons Integer data type
A constructor and appropriate gets accessors and sets mutators
A method that overrides the toString method in the base class. The CargoShip class's
toString method should display only the ship's name and the maximum number of tons
the ship can carry.
Create a ShipDemo program that asks the user to input ship data. The program should display a
menu that allows the user to enter ships until a is entered. The program should have a static
method called menu that displays the menu. After the user enters a the program should
display the ship information that was entered by the user using the toString methods created
for each type of ship.
Menu
Enter for a Ship
Enter for a Cruise Ship
Enter for a Cargo Ship
Enter to exit
Please enter your choice:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
