Question: Please write it in JAVA and write comments 1 . Ship, CruiseShip, and CargoShip Classes ( 6 0 pts ) ( Please use your first

Please write it in JAVA and write comments
1. Ship, CruiseShip, and CargoShip Classes(60pts)( Please use your first and last initials at the end of the program name. For example do ShipSK.java(Use your initials in place of SK)
Design a Ship class that the following members:
A field for the name of the ship (a string).
A field for the year that the ship was built (a string).
A constructor and appropriate accessors and mutators.
A toString method that displays the ships 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 (an int).
A constructor and appropriate accessors and mutators.
A toString method that overrides the toString method in the base class. The
CruiseShip classs toString method should display only the ships name and the
maximum number of passengers.
Design a CargoShip class that extends the Ship class. The CargoShip class should have the
following members:
A field for the cargo capacity in tonnage (an int).
A constructor and appropriate accessors and mutators.
A toString method that overrides the toString method in the base class. The
CargoShip classs toString method should display only the ships name and the ships
cargo capacity.
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 objects toString method.
2. RetailItem Class Handling Exceptions (40pts)
Refer to the attached pseudocode RetailItem that holds data about an item in a retail store. The class should have the following fields:
Description String object that holds a description of the item (Example Jacket, Designer Jeans, Shirt...)
UnitsOnHand int variable that holds the number of units currently in the inventory.
Price double variable that holds the items retail price
Write a constructor that accepts arguments for each field, appropriate mutator methods that store values in these fields, accessor methods that return the values in these fields. Write an exception class that can be instantiated and thrown when a negative number is given for the price. Write another exception class that can be instantiated and thrown when a negative number is given for the units in hand. Demonstrate the exception class in a program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!