Question

Now design a class named PassengerJet in the file named PassengerJet.java as a subclass of Jet...

Now design a class named PassengerJet in the file named PassengerJet.java as a subclass of Jet implemented in Problem 2 above.
This class should include the following attributes (fields):

l numPassengers that represents the number of passengers the jet can carry. l numEngines: The number of engines the Jet has l hasAutopilot: The aircraft has full autopilot capabilities. Additionally, write the following methods: l isHardToFly: This returns a Boolean. The jet is hard to fly if there is no autopilot. l needsLongRunway: This returns true if the grossEmptyWeight is greater than 500000 lbs. Also include at least one constructor that makes sense. Don’t forget to implement the Comparable interface in this class if you left it out of Jet and chose to do it at this level. Remember that you are inheriting some or all (depending on how you designed your superclass) of the attributes and methods defined in its superclass (Jet). Now, write a main method in this class that tests your implementation of PassengerJet.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

Please find the below code according to the problem statement:

Note: As the Jet class specifications are not provided in the problem statement, sample Jet class is considered for the implementation of PassengerJet class

====================================

PAssengerJet.java

====================================
public class PassengerJet extends Jet implements Comparable<PassengerJet> {

   private int numPassengers;
   private int numEngines;
   private boolean hasAutoPilot;

   public boolean isHardToFly() {
       if (!hasAutoPilot)
           return true;
       return false;
   }

   /**
   * @param manufacturer
   * @param grossWeightEmpty
   * @param model
   * @param year
   * @param owner
   * @param lastOverhaul
   * @param numOverhauls
   * @param maxRecommendedFlightHours
   * @param numPassengers
   * @param numEngines
   * @param hasAutoPilot
   */
   public PassengerJet(String manufacturer, double grossWeightEmpty, String model, int year, String owner,
           int lastOverhaul, int numOverhauls, int maxRecommendedFlightHours, int numPassengers, int numEngines,
           boolean hasAutoPilot) {
       super(manufacturer, grossWeightEmpty, model, year, owner, lastOverhaul, numOverhauls,
               maxRecommendedFlightHours);
       this.numPassengers = numPassengers;
       this.numEngines = numEngines;
       this.hasAutoPilot = hasAutoPilot;
   }

   public boolean needsLongRunWay() {
       if (super.getGrossWeightEmpty() > 500000)
           return true;
       return false;
   }

   /*
   * implementing the comparable interface for the PassengerJet using number of
   * passengers in that Jet.
   * The Passenger Jet which can have higher passenger is considered the bigger one
   *
   * @see java.lang.Comparable#compareTo(java.lang.Object)
   */
   @Override
   public int compareTo(PassengerJet o) {
       return this.numPassengers-o.numPassengers;
   }

  
   public static void main(String[] args) {
      
       PassengerJet pJet = new PassengerJet("Boeing", 650000, "747", 2015, "Asiana", 8, 2, 25, 1000, 2, true);
      
       PassengerJet pJet2 = new PassengerJet("Lockheed",450000,"DC-10",2017,"Rockwell Collins",7,3,16,750,2,false);
      
       System.out.println("Passenger Jet-1 is hard to fly : "+pJet.isHardToFly());
       System.out.println("Passenger Jet-1 needs a long runway to land : "+pJet.needsLongRunWay());
       System.out.println("***************************");
       System.out.println("Passsenger Jet 2 is hard to fly : "+pJet2.isHardToFly());
       System.out.println("Passenger Jet-2 needs a long runway to land : "+pJet2.needsLongRunWay());
       System.out.println("***************************");
       System.out.println("Passenger Jet-1 comare to Passenger Jet-2 : "+pJet.compareTo(pJet2));
      
   }
}

Sample output:

e Console X <terminated> PassengerJet [Java Application] C:\Program Files\Java\jdk-11.0.1\bin\javaw.exe (Jun Passenger Jet-1

I Hope this helps you!!

Thanks

Add a comment
Know the answer?
Add Answer to:
Now design a class named PassengerJet in the file named PassengerJet.java as a subclass of Jet...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In Java Which of the following statements declares Salaried as a subclass of payType? Public class...

    In Java Which of the following statements declares Salaried as a subclass of payType? Public class Salaried implements PayType Public class Salaried derivedFrom(payType) Public class PayType derives Salaried Public class Salaried extends PayType If a method in a subclass has the same signature as a method in the superclass, the subclass method overrides the superclass method. False True When a subclass overloads a superclass method………. Only the subclass method may be called with a subclass object Only the superclass method...

  • Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define...

    Please answer all the questions 2. Design two programs named BaseClass and SubClass. In BaseClass, define a variable xVar (type: char, value: 65), and a method myPrint to print xVar. SubClass is a subclass of BaseClass. In SubClass, define a variable yVar (type: int, value: 16) and another variable strVar (type: String, value: "java program!"). There is also a method myPrint to print the value of yVar and strVar in SubClass, as well as an additional method printAll, in which...

  • You must create a Java class named TenArrayMethods in a file named TenArrayMethods.java. This class must...

    You must create a Java class named TenArrayMethods in a file named TenArrayMethods.java. This class must include all the following described methods. Each of these methods should be public and static.Write a method named getFirst, that takes an Array of int as an argument and returns the value of the first element of the array. NO array lists. Write a method named getLast, that takes an Array of int as an argument and returns the value of the last element...

  • ATM Revisited In Java, design a subclass of the Account class called GoldAccount. It is still...

    ATM Revisited In Java, design a subclass of the Account class called GoldAccount. It is still an Account class, however it has an additional field and some additional functionality. But it will still retain all the behavior of the Account class. Write a class called GoldAccount. This class will have an additional private field called bonusPoints. This field will require no get or set methods. But it will need to be initialized to 100 in the constructor. Thereafter, after a...

  • The class Engineer Test below is used to test two other class named Project & Engineer....

    The class Engineer Test below is used to test two other class named Project & Engineer. A project has three attributes: projNo (int), projName (string), revenue (double). Add a parameterized constructor, and setters & getters for all attributes. An engineer has four attributes: jobld (int), name (string), rate (double), and a list of projects. For each project, the engineer has a specific amount as profit (project revenue rate). Add a constructor that initializes the attributes: jobild, name and rate. Implement...

  • Hello! This is C++. Q3. Write a program Define a Super class named Point containing: An...

    Hello! This is C++. Q3. Write a program Define a Super class named Point containing: An instance variable named x of type int. An instance variable named y of type int. Declare a method named toString() Returns a string representation of the point. Constructor that accepts values of all data members as arguments. Define a Sub class named Circle. A Circle object stores a radius (double) and inherit the (x, y) coordinates of its center from its super class Point....

  • Problem 2 (36 pts): You are going to design a class named Computer. The class contains:...

    Problem 2 (36 pts): You are going to design a class named Computer. The class contains: A string field named manufacturer. A string field named serialNumber. A double field named speed (measured in Gigahertz). A constructor that has a parameter for each data field and sets the data fields with these values. A no-arg constructor that sets string fieldsto and numeric fields to 0. Mutator and Accessor methods for each data field. A method toString) that returns each field value...

  • Create a class named Horse that contains data fields for the name, color, and birth year....

    Create a class named Horse that contains data fields for the name, color, and birth year. Include get and set methods for these fields. Next, create a subclass named RaceHorse, which contains an additional field that holds the number of races in which the horse has competed and additional methods to get and set the new field. Write an application that demonstrates using objects of each class. Save the files as Horse.java, RaceHorse.java, and DemoHorses.java. Program 1 Submission Template Fields:...

  • 1. Create a class named Pizza with data fields dor desceiption ( such as sasuage and...

    1. Create a class named Pizza with data fields dor desceiption ( such as sasuage and onion) and price. include a constructor fhay requires arguments for borh fields ans a method to diplay the data. Create a subclass names DelicedPizza that inherits from Pizza bit adds a delivery fee and a delicery address. The description, price, and delicery address are required as arguments to the constructor. The delivery fee is $3 if the pizza ordered cost more that $15; otherwise...

  • In PYTHON 3- Implement a subclass (described below) of "Word Guess", a variant of the game...

    In PYTHON 3- Implement a subclass (described below) of "Word Guess", a variant of the game Hangman. In this game, a word is first randomly chosen. Initially, the letters in the word are displayed represented by "_”.   For example, if the random word is "yellow”, the game initially displays "_ _ _ _ _ _”. Then, each turn, the player guesses a single letter that has yet to be guessed. If the letter is in the secret word, then the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT