Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Design a Ship class that has the following class members: A field for the name of the ship A field for the year the ship

Design aShipclass that has the following class members:

A field for the name of the ship

A field for the year the ship was built

A constructor

Appropriate accessors and mutators

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

Design aCruiseShipclass the inherits from the Ship class. Include the following members:

A field for the max number of passengers

A constructor

Appropriate accessors and mutators

toString method that overrides the Ship toString method. The method should display the ship name and the max number of passengers

Design aCargoShipclass that inherits from the Ship class. Include the following members:

A field for cargo capacity (tons)

A constructor

Appropriate accessors and mutators

toString method that overrides the base class. The method should display ships name and cargo capacity.

Demonstrate these classes in a program that creates two objects from each class and stores them in an ArrayList of Ship objects. Use the following information:

Ship- NSU Vic , 1884

Ship- NSU Column, 1902

Cruise Ship- Java Queen 1, 2003, 450

Cruise Ship- CIS Minnow, 2010, 250

Cargo Ship- Demon 1, 1999, 7000

Cargo Ship- Demon 2, 1993, 10000

Step through the ArrayList and call the toString method for each object.

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

Seven NoSQL Databases In A Week Get Up And Running With The Fundamentals And Functionalities Of Seven Of The Most Popular NoSQL Databases

Authors: Aaron Ploetz ,Devram Kandhare ,Sudarshan Kadambi ,Xun Wu

1st Edition

1787288862, 978-1787288867

More Books

Students also viewed these Databases questions

Question

Identify the three methods used to value stock.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago