Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming language Java 2 Please i need it quickly Question 1 [40 pts] Implement the below classes and interface as presented in the following UML

image text in transcribedimage text in transcribedimage text in transcribedProgramming language Java 2

Please i need it quickly

Question 1 [40 pts] Implement the below classes and interface as presented in the following UML diagram except 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 + compareTo(o:E):int Aircraft - speed: double Aircraft(speed: double) +toString(:String allowedWeight(): double Fleet - aircrafts: Aircraft + Fleet(size: int) + addAircraft (a: Aircraft): void + aircraftAt(ind:int): Aircraft +fastestAircraft(): Aircraft Fighter -arming Weight: double +Fighter(speed:double, arming Weight:double) +toString():String CivilAircraft -capacity: int +CivilAircraft(speed:double capacity:int) +toString():String A. [6 pts] Write the abstract class Aircraft as presented in the above UML. a) Write the constructor. b) Write the toString() method. c) Write the abstract method allowedWeight(). C. [14 pts) 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. (20 pts] 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 aircraftAt(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 [20 points] 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 fleet. d) Ask the user to enter an index then display the aircraft in the fleet at this index otherwise display an error message

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions