JAVA!!! PLZ !!!! JAVA public class Plane { private String airline; private String model; private double mileage; private float flightHours; final int AVG_SPEED = 550;//average
JAVA!!! PLZ !!!! JAVA
public class Plane { private String airline; private String model; private double mileage; private float flightHours; final int AVG_SPEED = 550;//average speed of the plane in mph final int MAX_SPEED = 750;//max speed of the plane in mph public Plane(){ mileage = 0.0; flightHours = 0.0f; airline = "LATAM"; model = "Boeing 787"; } public Plane(String airline, String model, double mileage, float flightHours){ this.airline = airline; this.model = model; this.mileage = mileage; this.flightHours = flightHours; } public void setAirline(String airline){ this.airline = airline; } public String getAirline(){ return airline; } public void setModel(String model){ this.model = model; } public String getModel(){ return model; } // TODO: add the missing getters/setters for mileage and flightHours // TODO: add the 4 overloaded fly methods
}
Plane class (method overload) Complete the code for the class Plane. The variable mileage refers to the accumulated number of miles that a plane has traveled and the variable hoursFlight refers to the accumulated number of hours that a plane has traveled. Here is the definition of the four variants of the method fly (speed of the plane is given in mph), written in UML notation: + fly(hours: float) + fly(miles: double) + fly hours: flight, speed: int) + fly(miles: double, speed: int) Whenever a flight is taken by executing the method fly in any of its four variants, the mileage and the flightHours need to be updated accordingly. When speed is not provided in the method fly, you need to use the constant AVG_SPEED. If the provided speed is greater that the MAX_SPEED, you need to use MAX_SPEED You also need to complete the getters/setters for mileage and flightHours (Note: no negative or zero mileage flightHours or speed are allowed, if that happens, current values of mileage and flightHours must be kept the same) More instructions on how to implement the missing parts of this class are provided in the code below. 2 1 public class Plane { private String airline: 3 private String model: private double mileage: 5 private float flightHours: 4 6 7 550://average speed of the plane final int AVG_SPEED in mph final int MAX_SPEED mph 8 750://max speed of the plane in 9 10 11 12 public Plane () { mileage = 0.0: flightHours = 0.0f: airline = "LATAM" ; model "Boeing 787" : 13 14 model = "Boeing 787" ; 14 15 } 16 17 18 19 public Plane (String airline, String model, double mileage, float flightHours) { this. airline airline: this, model = model: this. mileage mileage: this. flightHours = flightHours: } 20 = 21 22 23 24 25 public void setAirline (String airline) { this. airline = airline; } 26 27 28 29 30 31 32 33 public String getAirline () { return airline : } public void setModel (String model) { this. model = model: } 34 35 36 37 38 39 40 public String getModel() { return model: } // TODO: add the missing getters/setters for mileage and flightHours 41 42 43 // TODO: add the 4 overloaded fly methods 44 45 46 47 48Step by Step Solution
There are 3 Steps involved in it
Step: 1
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