[SOLVED] CSIT121 Lab3-Design and implement abstract class and interface

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon CSIT121_JavaLab3-cy1z8j.zip (836.1 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (1 vote)

Following completion of this task, students should be able to:

  • Design and implement abstract class and interface

Question 1

Declare and implement an abstract class called Ship that has the following:

  • An attribute to represent the name of the ship.
  • An attribute to represent the year that the ship was built.
  • A default constructor to initialize the attributes.
  • Accessor methods and mutator methods for each of the attribute.
  • An abstract method called displayDetails().

Declare and design a subclass of Ship called CruiseShip. The CruiseShip class should have the following: § An additional attribute to keep the maximum number of passengers.

  • A default constructor to initialize the attribute in CruiseShip as well as the Ship § Accessor methods and mutator methods for its attribute.
  • The displayDetails()method that will display all details from Ship and CruiseShip.

Declare and implement another subclass of Ship called CargoShip. The CargoShip class should have the following:

  • An attribute to keep the cargo capacity in tonnage.
  • A default constructor to initialize the attribute in CargoShip as well as the Ship § Accessor methods and mutator methods for its attribute.
  • The displayDetails()method that will display all details from Ship and CargoShip.

Write a main() method in another class called ShipApp. Declare an ArrayList<Ship> to keep several CruiseShip and CargoShip objects. Use a simple menu to allow the user to

  • add either a CruiseShip or a CargoShip
  • edit either the number of passengers for a CruiseShip or the cargo capacity for the CargoShip
  • display all the objects in the ArrayList.

 

  • CSIT121_JavaLab3-cy1z8j.zip