Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 59 2 Points A class named Flight has been defined. It has the following instance data items: . private String airline, origin, destination; private

image text in transcribed
Question 59 2 Points A class named Flight has been defined. It has the following instance data items: . private String airline, origin, destination; private int flightNumber ; Sample data might be: Delta, LEX, MIA, 8109 meaning this is a Delta flight from the LEX airport (Lexington, KY) to the MIA airport (Miami, FL) on flight number 8109. An airline is adding Business flights and wants a child class of Flight, called BusinessFlight. This new child class should have the following fields (instance data variables). . client (String) . passengers (int) . ticketPrice ( double ) . booking Charge ( double ) Sample data for the new class could be: Altech, 12, 625.75, 1500.00 meaning Altech wants to charter a plane for 12 passengers with a ticket price for each passenger of $625.75, and a booking charge of $1,500.00. Which of the following program segments is the best way to create a constructor with parameters (all data from parent and child) without redundant code (without repeated code in the child that was most likely done in the parent) and with proper input valid validation for child data? public BusinessFlight(String client, int passengerCount, double ticketPrice, double bookingCharge) super(); if (passengerCount >0) this.passengerCount = passengerCount ; else this.passengerCount = 0; if (ticketPrice > 0.0) this.ticketPrice = ticketPrice ; ved 9:40:48 PM

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_2

Step: 3

blur-text-image_3

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Beveridge countries typically feature single-payer insurance.

Answered: 1 week ago