Computers and Technology

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.

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 23:50, Emptypockets451
You need to design a circuit that implements the functions in the following table: s0 s1 function0 0 a + 10 1 a – b1 0 a + b1 1 a – 1s0 and s1 are 1-bit control inputs to select the function of the circuit. inputs a and b are 4-bitnumbers in 2s complement form. the output is also a 4-bit number in 2s complement form. you are allowed to use only one ttl 7483 4-bit adder to implement all the functions. but anynumber of other components (except the adder) can be used. hint: design a combinational logic circuit to modify the input b and the “carry input” of theadder depending on the control inputs s0 and s1.important: lab grade will depend on the working of the circuit & will be checked of by your labinstructor.1. is the output valid for the following input combinations: a. s0 = 0, s1 = 0, a = 7, b = 3? b. s0 = 0, s1 = 1, a = 7, b = 3? c. s0 = 1, s1 = 0, a = -4, b = -5? d. s0 = 1, s1 = 1, a = -8, b = 6? 2. what is the range of inputs (for both a and b) that will produce the valid output for all the functions?
Answers: 3
image
Computers and Technology, 23.06.2019 02:00, hctlawton
Which software would you use to create a print design? a. illustrator b. audacity c. reaper d. dreamweaver
Answers: 2
image
Computers and Technology, 23.06.2019 05:30, savyblue1724707
Sally is editing her science report about living things. she needs to copy a paragraph from her original report. order the steps sally needs to do to copy the text to her new document.
Answers: 1
image
Computers and Technology, 23.06.2019 06:00, ashleyd198308
Respond to the following in three to five sentences. select the workplace skill, habit, or attitude described in this chapter that you believe is most important for being a successful employee.
Answers: 1
Do you know the correct answer?
Design a Ship class with the following members:

• Two private fields: name of the ship...

Questions in other subjects:

Konu
Mathematics, 16.03.2022 07:30
Konu
English, 16.03.2022 07:30