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
Get step-by-step solutions from verified subject matter experts
