Question: (in java program language ) a. Write an abstract class CommercialFlight with the following features: Instance Variables: name (String), id (int), a final field numberOfFlights

(in java program language )

a. Write an abstract class CommercialFlight with the following features: Instance Variables: name (String), id (int), a final field numberOfFlights (int). (numberOfFlights should be above zero, otherwise throw IllegalArgumentException) Abstract Methods: a totalCharge() method which returns the total charge for the flight. Constructor. Methods: Accessor methods, toString() method which displays the name and id of the flight and its total charge (returned by the total charge method). b. Write a subclass of CommercialFlight called Express. The class Express consists of the following additional instance variables: chargePerFlight (double) (chargePerFlight should be above zero, otherwise throw IllegalArgumentException). Implement the totalCharge() method (by multiplying the chargePerFlight by the numberOfFlights) and the method equals. c. Create a test class to demonstrate all your classes capabilities. Catch IllegalArgumentException.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!