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 15:00
Plz ( which is an example of a good url?
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Based on the current economic situation do you expect the employment demand for graduating engineers to increase or decrease? explain the basis for your answer. with a significant economic recovery, what do you think will happen to future enrollments in graduating engineering programs?
Answers: 1
question
Computers and Technology, 24.06.2019 10:30
This device directs network traffic. bridge hub nic repeater router switch
Answers: 3
question
Computers and Technology, 24.06.2019 23:30
True or false when a host gets an ip address from a dhcp server it is said to be configured manually
Answers: 1
You know the right answer?
Design a Ship class with the following members:

• Two private fields: name of the ship...
Questions
Questions on the website: 13722367