Question: CODED IN JAVA PLEASE Ship, CruiseShip, and CargoShip Classes Design a Ship class that the following members: A field for the name of the ship

CODED IN JAVA PLEASE

Ship, CruiseShip, and CargoShip Classes Design a Ship class that the following members:

A field for the name of the ship (a string).

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

A constructor and appropriate accessors and mutators.

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

Design a CruiseShip class that extends the Ship class.

The CruiseShip class should have the following members:

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

A constructor 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.

Design a CargoShip class that extends the Ship class.

The CargoShip class should have the following members:

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

A constructor 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.

Demonstrate the classes in a program that has a Ship array.

Assign various Ship, CruiseShip, and CargoShip objects to the array elements.

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

----------------Sample Output----------------------------------------------------------------------------------------------------------------------

How many ships are there?

4

What is the name of the ship # 1?

Carnival

When was the ship built?

2010

Is it a (1) Cargo ship (2) Cruise ship (3) Other ship ?

2

What is the maximum number of passengers?

4000

What is the name of the ship # 2?

High Seas

When was the ship built?

2014

Is it a (1) Cargo ship (2) Cruise ship (3) Other ship ?

1

What is the capacity in tons?

50000

What is the name of the ship # 3?

Caught Fishing

When was the ship built?

2016

Is it a (1) Cargo ship (2) Cruise ship (3) Other ship ?

3

What is the name of the ship # 4?

Princess

When was the ship built?

2000

Is it a (1) Cargo ship (2) Cruise ship (3) Other ship ?

2

What is the maximum number of passengers?

3500

Here are your ships:

Type: Cruise Ship

Name: Carnival

Year built: 2010

Name: Carnival

Maximum passengers: 4000

----------------------------

Type: Cargo Ship

Name: High Seas

Year built: 2014

Name: High Seas

Cargo capacity: 50000 tons

----------------------------

Name: Caught Fishing

Year built: 2016

----------------------------

Type: Cruise Ship

Name: Princess

Year built: 2000

Name: Princess

Maximum passengers: 3500

----------------------------

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!