Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Focus On Geodatabases In ArcGIS Pro

Authors: David W. Allen

1st Edition

1589484452, 978-1589484450

More Books

Students also viewed these Databases questions