subject

Design a Ship class with the following members:

• Two private fields: name of the ship and the year it was built.
• A no-arg constructor and a constructor that takes two arguments (name and year).
• Appropriate getters and setters.
• A toString method that overrides the toString method in Object and displays the ship's 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 (int).
• A constructor and appropriate accessors and mutators.
• A toString 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.

Design a CargoShip class that extends the Ship class. The CargoShip class should habe the following members:

•A field for the cargo capacity in tonnage (int).
•A constructor and appropriate accessors and mutators.
•A toString 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 ship's cargo capacity.

Required:
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 object's toString method.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 07:30
What is the penalty for violating section 1201 of title 17 chapter 21 of the us code
Answers: 1
question
Computers and Technology, 23.06.2019 08:00
Match the items with their respective descriptions.
Answers: 1
question
Computers and Technology, 23.06.2019 16:00
What is the biggest difference between section breaks and regular page breaks? section breaks are more difficult to add than page breaks. section breaks make it easier for you to view the document as an outline. section breaks allow you to have areas of the document with different formatting. section breaks are smaller than regular page breaks.
Answers: 2
question
Computers and Technology, 24.06.2019 00:50
Which of the following is not a key player in the sale of travel products?
Answers: 2
You know the right answer?
Design a Ship class with the following members:

• Two private fields: name of the ship...
Questions
question
Mathematics, 05.05.2020 17:23
question
Mathematics, 05.05.2020 17:23
question
Social Studies, 05.05.2020 17:23
question
Biology, 05.05.2020 17:23
Questions on the website: 13722361