1. The following are the class definition for Ship, and CruiseShip. Simplied the class definition by using inheritance. public class Ship{ private String name; private int year; Ship (String name, int...


1. The following are the class definition for Ship, and CruiseShip. Simplied the class<br>definition by using inheritance.<br>public class Ship{<br>private String name;<br>private int year;<br>Ship (String name, int year) {<br>this.name = name;<br>this.year = year;<br>}<br>public void setName (String name) {<br>this.name = name;<br>}<br>public void setYear (int year){<br>this.year = year;<br>}<br>public String getName () {<br>return name;<br>}<br>public int getYear () {<br>return year;<br>}<br>public void display () {<br>System.out.println (

Extracted text: 1. The following are the class definition for Ship, and CruiseShip. Simplied the class definition by using inheritance. public class Ship{ private String name; private int year; Ship (String name, int year) { this.name = name; this.year = year; } public void setName (String name) { this.name = name; } public void setYear (int year){ this.year = year; } public String getName () { return name; } public int getYear () { return year; } public void display () { System.out.println ("Ship's name: "+name); System.out.println ("Year it was built: "+year); } public class CruiseShip{ private String name; private int year; private int maxPassenger; CruiseShip (String name, int year, int maxPassenger) { this.name = name; this.year = year; this.maxPassenger = maxPassenger; public void setName (String name) { this.name = name; } public void setYear (int year) { this.year = year; } public void setMaxPassenger (int maxPassenger) { this.maxPassenger = maxPassenger; } public String getName () { return name; } public int getYear () { return year; } public int getMaxPassenger () { return maxPassenger; } public void display () { System.out.println ("Ship's name: "+name); System.out.println ("Year it was built: "+year); System.out.println ("Maximum number of passengers: "+maxPassenger); } Demonstrate the class in a simple program. Draw UML diagrams for Ship, and CruiseShip that shows inheritance.

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here