Question: In java GUI Design a Ship class with the following information: Name Year A constructor and appropriate accessors and mutators toString method A speed method
In java GUI
Design a Ship class with the following information:
Name
Year
A constructor and appropriate accessors and mutators
toString method
A speed method to calculate/determine the spped(generate a random value for the speed between 30 50 knots per hour).
Design a CruiseShip class that extends the Ship class. The CruiseShip class will have the following:
Maximum passengers
A constructor and appropriate accessors and mutators
A toString that displays the ships name and number of passengers. (override the base class toString)
Override the speed method where the speed = (random value between 50 70) (.1 * # passengers * 200). If the value is negative take the absolute value
Design a CargoShip class that extends the Ship class. The CargoShip class will have the following:
Cargo capacity
A constructor and appropriate accessors and mutators
A toString that displays the ships name and capacity. (override the base class toString)
Override the speed method where the speed = (random value between 40 50) (.001 * cargo size)
Demonstrate the classes in a GUI program that has a Ship array. Assign the various ships to the array and allow the user to step through the array.
Your application will be able to read a text file containing ship information. The data file will be in the following format, where each data member is separated by a colon:For a ship:
For a CruiseShip:
For a CargoShip:
The ship type is a number in the range listed below. A type number out of this range can be ignored.
| | Range |
| Ship | 1-49 |
| CruiseShip | 100-200 |
| CargoShip | 50-99
|
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
