Question: In this question you are to create a Ship class and a CruiseShip class (derived from the Ship class). All instructions are in comments in

In this question you are to create a Ship class and a CruiseShip class (derived from the Ship class). All instructions are in comments in the classes. You also need to complete the main method. You have been asked to write methods that are not used in this program - write them anyway because I will grade them. If in doubt, check out the rubric I have put in canvas.

Main.java

public class Main {

public static void main(String[] args) { Scanner scnr = new Scanner(System.in); //create two cruiseships String name = scnr.next(); int yearBuilt = scnr.nextInt(); int capacity = scnr.nextInt(); CruiseShip s1 = new CruiseShip(name, yearBuilt, capacity); name = scnr.next(); yearBuilt = scnr.nextInt(); capacity = scnr.nextInt(); CruiseShip s2 = new CruiseShip(name, yearBuilt, capacity); //write code to output which is larger //you must use compareTo //do not put them into an arrayList or array. Do not sort using a sort such as Collections sort. if( ) System.out.println(s1.getName() + " is larger"); else if ( ) System.out.println(s2.getName() + " is larger"); else System.out.println("They are the same size"); } }

Ship.java

//ship has attributes //name (a String) //and //yearBuilt (an int) //write constructors, ALL mutators and accessors, and a writeOutput . //even though these are mostly unused in this program, you need to write them to get a grade public class Ship {

}

CruiseShip.java

/* *CruiseShip inherits from Ship and has an attribute called capacity (an int) which is the maximum number of passengers write all constructors, accessors, and mutators write a writeOutput method. Write a compareTo that compares according to the capacity

*/

public class CruiseShip { }

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!