Question: java Implement the below classes and interface as presented in the following UML diagram exeept the class Fighter for which you will find the code
java



Implement the below classes and interface as presented in the following UML diagram exeept the class Fighter for which you will find the code provided below. For all classes implement only the getters that you will need later in your code. > Comparable + compare Tolo::int Aircrali Fleet - Speed: double - aircrafts: Aircraft + Aircraft(speed: double) + Fleet(size: int) toString() String + addAircraft (a: Aircraft): void + allowedWeight) double + aircraft Alindrint): Aircraft + fastestAircraft(): Aircraft Fighter -arming Weight: double +Fighter speed double,arming Weight:double) HoString:String CivilAircraft -capacity.int +CivilAircraft(speed:double cup toString():String city int) A. Write the abstract class Aireraft as presented in the above UML. a) Write the constructor b) Write the toString() method c) Write the abstract method allowedWeight(). B. Do not implement the class Fighter. The code is: public class Fighter extends Aircraft private double armingheight: public Fighter (double speed, double armingWeight) super (speed) this.armingWeight - armingWeight public double allowed eight return armingWeight+200 public String toString() return super. toString() + ", arming weight - "+armingWeight ", and allowed weight allowedWeight(); c. Implement the class CivilAircraft. It has one private data, capacity, that indicates the maximum number of passengers that can be transported. a) Write the constructor b) Implement the allowedWeight method. The average weight per passenger including baggage is 120kg, The allowed weight for a civil aircraft is the sum of the average weights for all passengers and 900kgs reserved for staff members. c) Implement the compareTo method of the Comparable Interface. Two aircrafts are comparable by their allowed weight d) Write the toString() method returns a description of the form: **Speed -...", capacity and allowed weight - ... D. Implement the class Fleet that has as data an array of n aircrafts. a) Write the constructor, which creates an empty collection of Aircrafts. The size of this array is passed as a parameter to the constructor of the class Fleet b) Write the method addAircraft (A: Aircraft) which adds a CivilAircraft or a Fighter object to the collection c) Write the method aircraftAl(ind: int) which returns the aircraft in the collection at the index ind if the index is valid. Otherwise, it should return null. d) Write the method fastestAircraft (which returns the aircraft with the max speed in the collection, Question 2 Implement the driver class (application) as follows: a) Create a Fleet object, 2 fighters, and 3 civil aircrafts. Add the fighters and the civil aircrafts to the fleet b) Write code to compare the civil aircrafts to display a message showing which one has the larger allowed weight c) Write code to find and display the fastest aircraft in the flect. d) Ask the user to enter an index then display the aircraft in the fleet at this index otherwise display an error message: Part II: ArrayList and Inheritance Question 1 Implement the class Vehicle only. The code of the classes Bicycle and Car is provided below. Vchiele W brand: String #model: String #price: double #cheekin: Amaylist-String + Vehicle + Vehicle --All parameters + adeCheckinLocation: String) + removeCheckInLocation (p: String) + String String Bicycle (Do not implement this class) Car geasCount: Bicycle (All parameters...) toString String fuel Type: String CarAll parameters +toString String A. The Vehicle class is characterized by four data fields: a String brand, a String model, a double price and an array list of strings checkin. Write the following methods: a) Two constructors (as shown in the UML). b) Getters and setters (only for the attributes brand and price). .) addCheckInLocation method that takes as parameter the name of a location to be added to the array list. If this name already exist in the list the message "EXIST" must be displayed d) removeCheckInLocation method that takes as parameter the name of the location to be deleted from array list. e) A toString method to retum information about all data fields
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
