Question: Given the UML, output and starter code I have to complete the program. Ship - name : String - yearBuilt : String + Ship(n :
Given the UML, output and starter code I have to complete the program.



Ship - name : String - yearBuilt : String + Ship(n : String, y: String) + setName(n : String) : void + set YearBuilt(y : String) : void + getName() : String + getYearBuilt() : String + toString() : String CargoShip tonnage: int Cruise Ship passengers : int + Cruise Ship(n : String, y : String, p : int) + setPassengers(p : int) : : void + getPassengers() : int + toString() : String + CargoShip(n : String, y: String, t : int) + set Tonnage(t : int) : void + getTonnage() : int + toString() : String Marzelli: Ship Name: Lolipop Year built: 1960 Name: Disney Magic Maximum passengers: 2400 Name: Black Pearl Cargo capacity: 50000 tons /** * Chapter 9 * Programming Challenge 10: Ship, CruiseShip, and CargoShip Classes * This program demonstrates the Ship, Cruiseship, and CargoShip Classes. */ public class ShipDemo { public static void main(String[] args) { 1/ Constant for the number of ships. final int NUM_SHIPS = 3; // Create an array of Ship references. Ship[] ships = new Ship[NUM_SHIPS]; // Assign Ship objects to the array elements. ships [0] = new Ship("Lolipop", "1960"); ships[1] = new CruiseShip("Disney Magic", "1998", 2400); ships [2] = new CargoShip("Black Pearl", "1800", 50000); // Call each object's toString method. for (int index = 0; index
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
