Question: 1. Ship: 1. Create an interface ShipInterface for the Ship class listing all method definitions. 2. Design a Ship class (base class) with: A field

1. Ship: 1. Create an interface ShipInterface for the Ship class listing all method definitions.

2. Design a Ship class (base class) with: A field for the name of the ship (a string).

A field for the year that the ship was built (a string).

Default and parameterized constructors and appropriate accessors and mutators.

A toString method that displays the ships name and the year it was built.

2. CruiseShip: 1.Create an interface for the CruiseShip class, CruiseShipInterface which extends the ShipInterface.

List all method definitions.

2. Implement the CruiseShipInterface in the CruiseShip class that extends the Ship class. The CruiseShip class should have the following:

A field for the maximum number of passengers (an int).

Default and parameterized constructors and appropriate accessors and mutators.

A toString method that overrides the toString method in the base class.

?The CruiseShip classs toString method should display only the ships name and the maximum number of passengers.

3. CargoShip: 1.Create an interface for CargoShip class, CargoShipInterface that extends the ShipInterface.

List all method definitions.

2. Implement the CargoShipInterface in the CargoShip class that extends the Ship class. The CargoShip class should have the following:

A field for the cargo capacity in tonnage (an int).

Default and parameterized constructors and appropriate accessors and mutators.

A toString method that overrides the toString method in the base class.

?The CargoShip classs toString method should display only the ships name and the ships cargo capacity.

4. ShipDemo: (contains main() method)

Inside the main() method,

? Create a Ship array containing 3 elements.

? Using parameterized constructors, ? Assign the first array element as an object of the class Ship ? Assign the second array element as an object of the class CruiseShip

? Assign the third array element as an object of the class CargoShip

? The program should then step through the array, calling each objects toString method.

? Test to see if

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!