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
  • Write ONE application program by using the following requirements: Using JAVA File input and outp...

    Write ONE application program by using the following requirements: Using JAVA File input and output Exception handling Inheritance At least one superclass or abstract superclass: this class needs to have data members, accessor, mutator, and toString methods At least one subclass: this class also needs to have data members, accessor, mutator, and toString methods At least one interface: this interface needs to have at least two abstract methods At least one method overloading At least one method overriding At least...

  • 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...

  • q2: Write a public class named MythMouseListener that implements the Mouselistener interface. This class will have...

    q2: Write a public class named MythMouseListener that implements the Mouselistener interface. This class will have a public constructor that takes a JTextArea and a JLabel as parameters and stores these in instance variables. Override the mouseEntered method to . display the text from the JTextArea on the JLabel in all upper case letters. Then, override the mouseReleased method to display the text from the JTextArea on the JLabel in all lower case letters. The other three methods from the...

  • 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 interface class-like) Assume you have the Edible interface with its abstract method. Design a class named Animal a...

    (The interface class-like) Assume you have the Edible interface with its abstract method. Design a class named Animal and its two subclasses named Mammal and Dairy. Make Sheep and Bear as subclasses of Mammal and make implement the Edible interface. howToEat() and sound() are the main two methods for all edible classes while sound() is the main method for the non-edible classes. 1. Draw the UML diagram for the classes and the interface 2. Use Arraylist class to create an...

  • 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...

  • Problem: Coffee(Java) Design and implement a program that manages coffees. First, implement an abstract class named...

    Problem: Coffee(Java) Design and implement a program that manages coffees. First, implement an abstract class named Coffee. The Coffee class has three member variables: coffee type(does not mention the data type of the variable coffeeType), price, and store name. The Coffee class has an abstract method name ingredient. Make sure to add all necessary setters and getters as well as other methods. The class Coffee implements an interface HowToMakeDrink. The interface has the following method: public interface HowToMakeDrink { public...

  • 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....

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
ADVERTISEMENT