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 03:40
Hello my name is mihai and i need your : )i have to do a python project in computer science and i’m really busy with my mocks this period of time besides this i’m not good at coding so could someone pls pls pls sort me out ? i actually beg ; ))
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
How do you share someone else’s tweet with your own twitter followers?
Answers: 1
question
Computers and Technology, 24.06.2019 17:00
What are some examples of what can be changed through options available in the font dialog box? check all that apply. font family italicizing bolding pasting drop shadow cutting character spacing special symbols
Answers: 2
question
Computers and Technology, 25.06.2019 08:10
Java and c++ are examples of languagehigh-level languagesmachine languagecompiler languages
Answers: 1
You know the right answer?
Design a Ship class with the following members:

• Two private fields: name of the ship...
Questions
question
Spanish, 27.06.2019 08:30
Questions on the website: 13722366