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
Step: 1
Get Instant Access to Expert-Tailored Solutions
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