Answered step by step
Verified Expert Solution
Question
1 Approved Answer
could someone please finish this program it has on super class called ship and 3 sub classes with all setters and getters. Please add in
could someone please finish this program it has on super class called ship and sub classes with all setters and getters. Please add in the code that does this
create a driver class called FlotillaDriver that is
required to do specific tasks.
Open the text file called flotilla.csv and load all ship using
the appropriate subclass into an ArrayList dedicated to the
super class Ship.
Instantiate the proper sub ship object to add to the list. You
might need only the basic ship information in the initial list,
but when creating the displays using JOptionPane when one of the buttons is
clicked, you must provide the additional information of the
individual sub ship. Yoy should master the specific technique of loading all information from the
unique subclasses into a list of the superclass.
The organization for each line of data within the file starts
with the subship code that lets you know what type of sub
ship you have. The next six fields are the ships name, year of
built, country of registration, length, draft and beam. The
data following this depends on the the type of ship represent
ed At this point you will need to use a decision structure using loops and if statements
based on the subship code to determine how to access the
data.After you have successfully loaded the data, you need to con
figure a popup using the showOptionsDialog static method of the JOptionPane class.The Option buttons on this popup should be for each sub
ship and one to quit the program. Clicking on one of the subship options will produce the popups.
code so far:
class Ship
private String name; Ship name
private String nation; Nation of registry
private int year; digit year built
private int length; Length of ship at mean draft
private int draft; average depth below sea level
private int beam; side to side width at mean draft
public ShipString nam, String nat, int yer, int len, int dra, int bem
name nam;
year yer;
nation nat;
length len;
draft dra;
beam bem;
public int calculateDisplacment
return lengthbeamdraft;
public void setNameString n
name n;
public void setNationString na
nation na;
public String getName
return name;
public int getYear
return year;
public String getNation
return nation;
public String toString
return name
year
nation
"Size: length by beam by draft;
public int getLength
return length;
public int getDraft
return draft;
public int getBeam
return beam;
Subclass:
public class CargoShip extends Shipall setters and getters
private int maxCargo;
private int refrigiratedStorage;
public CargoShip String nam, String nat, int yer, int len, int dra,
int bem, int mcg int rst
supernam nat, yer, len, dra, bem;
maxCargo mcg;
refrigiratedStorage rst;
public String toString
return super.toString maxCargo refrigiratedStorage ;
subclass
public class Yacht extends Ship
private int numStateRooms;
private int poolSize;
private int numDecks;
private int power;
private int engineSize;
public YachtString nam, String nat, int yer, int len, int dra, int bem,
int nsrint pSize, int numDec, int pow, int eSize
supernam nat, yer, len, dra, bem;
numStateRooms nsr;
poolSize pSize;
numDecks numDec;
power pow;
engineSize eSize;
public String toString
return super.toString numStateRooms poolSize
numDecks power
;
subclass
public class CruiseShip extends Ship
private int numOfExecStateRooms;
private int numOfDoubleBunkRooms;
private int numOfQuadBunkRooms;
public CruiseShip String nam, String nat, int yer, int len, int dra,
int bem, int ner, int ndb int nqr
supernam nat, yer, len, dra, bem;
numOfExecStateRooms ner;
numOfDoubleBunkRooms ndb;
numOfQuadBunkRooms nqr;
public String toString
return super.toString
numOfExecStateRooms numOfDoubleBunkRooms
numOfQuadBunkRooms ;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started