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, 22.06.2019 17:00
Which of the following is not contained on the slide show toolbar? a. next button b. slide button c. close button d. pen too
Answers: 2
question
Computers and Technology, 23.06.2019 10:50
Your friend kayla is starting her own business and asks you whether she should set it up as a p2p network or as a client-server network. list three questions you might ask to kayla decide which network to use and how her answers to those questions would affect your recommendation.
Answers: 2
question
Computers and Technology, 24.06.2019 07:30
John recently worked on a project about various programming languages. he learned that though procedural language programs are useful, they have disadvantages too. what is a disadvantage of programs written in procedural languages? a. programs do not represent data complexity. b. programs take more time to execute. c. programs are prone to security threats. d. programs do not interface with multiple platforms.
Answers: 3
question
Computers and Technology, 24.06.2019 12:00
Jack is assisting his younger sibling mary with her mathematics assignment, which includes a study of the number system. jack explains to mary that whole numbers are counting numbers that could be used to record the number of fruits in a basket. which data type represents whole numbers? a.integers.b.floating-point numbers. c.strings.d.boolean
Answers: 1
You know the right answer?
Design a Ship class with the following members:

• Two private fields: name of the ship...
Questions
question
History, 16.12.2020 21:50
question
History, 16.12.2020 21:50
question
Mathematics, 16.12.2020 21:50
question
Mathematics, 16.12.2020 21:50
Questions on the website: 13722363