You are to use the Ship class you created in last weeks lab to create three subclasses. In the bundle of files that accompanies this lab, there is a Fleet Class. The Fleet Class requires these three...

1 answer below »
You are to use the Ship class you created in last weeks lab to create three subclasses. In the bundle of files that accompanies this lab, there is a Fleet Class. The Fleet Class requires these three sub classes inherited from the Ship class: specifically the CruiseShip, the CargoShip and the BattleShip. These sub classes will use all methods from the super class in addition to new attributes and methods unique to the specific class. The additional attribute per subclass are as follows: • The Cargo Ship subclass has both maximum cargo weight and freezer space. • The Cruise ship subclass has the number of state rooms (each berthing two passengers), number of double rooms (each berthing 2 passengers) and number of economy rooms (each berthing a single passenger). • The battle ship subclass has weapon capacity and troop carrying capacity. What are the names of these attributes? Well you know from the convention of writing getters which is to name the method getVariableName(), where variable name is the name of the attribute. So if you know the name of the getter, you know what the attribute should be called. In addition, in the file Fleet.java, you will see that both setters and getters for these subclasses are being used, so you know what the attributes name should be. 2 There is no code-along for this lab. There will still be codealongs in future labs, but fewer of them. I have provided you with a file bundle that contains the following file For part 1: • Ship.java ( my implementation of last weeks class) • fleet.java For part 2: • ship_info.java • fleet2.java Part 1: Creating the subclasses Your task for the first part of this exercise, is to write the sub classes with all the methods needed to run the Fleet class without changing anything in the Fleet class. In fact you, MAY NOT CHANGE ANY CODE within the Fleet class. Looking at the method calls in the Fleet class will also tell you the names of setters and getters methods. The data needed to instantiate these classes is hard coded in to the Fleet class. Remember the OOP principle that all class attributes should be private and as such need accessor and mutator methods. Remember the convention of writing an accessor and mutator method. Use the code written in the Fleet class for method names and parameter lists. Also, you are require to adhere to the setter and getter convention of having the attribute name reflected in the setter or getter. When you have completed the subclasses, you can compile and run the executable Fleet class. You should get the a display identical to the one to the right, without changing any code within the fleet class. The only differences might be if you are running your program on Windows. Then the display will have the MSWindows look-and-feel as opposed to the Mac look-and-feel as shown here. This first part it to make sure you subclasses are properly implemented. 3 Part 2 - More File IO: In the bundle of source code that accompanies this lab, you will also find a class called Fleet2. This class requires the data to be entered from a selected file. The file name selection and the display code has been provided for you. You need to provide the code that will load the data in from file. It is recommended that you use the scanner class. After you have successfully loaded the data. you should see the display to the right when you run the Fleet2 class. Now, to demonstrate that you understand what is going on in the Fleet2 code, you are to insert your name and the name of any team member between the list of ships and the beginning the the cargo fleet capacity and shown in red to the right. There should be a blank line both above and below your names.
Answered Same DayOct 28, 2021

Answer To: You are to use the Ship class you created in last weeks lab to create three subclasses. In the...

Shweta answered on Oct 30 2021
142 Votes
Solution70196/ShipFleet/build/built-jar.properties
#Fri, 30 Oct 2020 21:38:14 +0530
C\:\\Users\\Acer\\Documents\\NetBeansProjects\\ShipFleet=
Solution70196/ShipFleet/build/classes/.netbeans_automatic_build
Solution70196/ShipFleet/build/classes/.netbeans_update_resources
Solution70196/ShipFleet/build/classes/Fleet/BattleShip.class
package Fleet;
public synchronized class BattleShip extends Ship {
int weapons;
int fighters;
public void BattleShip(String, int, String, int, int);
public int getWeapons();
public int getFighters();
}
Solution70196/ShipFleet/build/classes/Fleet/CargoShip.class
package Fleet;
public synchronized class CargoShip extends Ship {
int maxTonnage;
int freezerSpace;
public void CargoShip(String, int, String, int, int);
public int getMaxTonnage();
public int getFreezerSpace();
}
Solution70196/ShipFleet/build/classes/Fleet/CruiseShip.class
package Fleet;
public synchronized class CruiseShip extends Ship {
int doubleCabins;
int stateCabins;
int economyCabins;
public void CruiseShip(String, int, String, int, int, int);
public int getDoubleCabins();
public int getStateCabins();
public int getEconomyCabins();
}
Solution70196/ShipFleet/build/classes/Fleet/Fleet$1.class
package Fleet;
final synchronized
class Fleet$1 implements Runnable {
void Fleet$1();
public void run();
}
Solution70196/ShipFleet/build/classes/Fleet/Fleet.class
package Fleet;
public synchronized class Fleet {
private Ship[] shipsOfFleet;
public void Fleet();
private String countTheFleet();
private String makeFleetRoster();
public static void main(String[]);
}
Solution70196/ShipFleet/build/classes/Fleet/Fleet2$1.class
package Fleet;
final synchronized class Fleet2$1 implements Runnable {
void Fleet2$1();
public void run();
}
Solution70196/ShipFleet/build/classes/Fleet/Fleet2.class
package Fleet;
public synchronized class Fleet2 {
private Ship[] shipsOfFleet;
private int MARK_LIMIT;
public void Fleet2();
public boolean loadShipsFromFile(String);
public static String enterFileName(String);
private String countTheFleet();
private String makeFleetRoster();
public static void main(String[]);
}
Solution70196/ShipFleet/build/classes/Fleet/Ship.class
package Fleet;
synchronized class Ship {
private String name;
private int yearBuilt;
private String nation;
public void Ship(String, int, String);
public void setName(String);
public void setYearBuilt(int);
public String getName();
public int getYearBuilt();
public String toString();
}
Solution70196/ShipFleet/build/classes/Fleet$1.class
final synchronized class Fleet$1 implements Runnable {
void Fleet$1();
public void run();
}
Solution70196/ShipFleet/build/classes/Fleet2$1.class
final synchronized class Fleet2$1 implements Runnable {
void Fleet2$1();
public void run();
}
Solution70196/ShipFleet/build.xml

Builds, tests, and runs the project ShipFleet.


Solution70196/ShipFleet/manifest.mf
Manifest-Version: 1.0
X-COMMENT: Main-Class will be added automatically by build
Solution70196/ShipFleet/nbproject/build-impl.xml















































































































































































































Must set src.dir
Must set test.src.dir
Must set build.dir
Must set dist.dir
Must set build.classes.dir
Must set dist.javadoc.dir
Must set build.test.classes.dir
Must set build.test.results.dir
Must set build.classes.excludes
Must set dist.jar




































































































Must set javac.includes
































































































































No tests executed.











































































































































































...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here