A class named Flight has been defined. It has the following instance data items: private...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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) A • passengers (int) • ticketPrice (double) • bookingCharge (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 ; 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) A • passengers (int) • ticketPrice (double) • bookingCharge (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 ;
Expert Answer:
Answer rating: 100% (QA)
Code public BusinessFlightString client int passengerCount double ticketPrice double bookingCharge s... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
Part 1: How long does it take for an investment to double in value if it earns (a) 4%, (b) 6%, (c) 9%, (d) 12%, (e) 15% annual compound interest? Solve above using method of 1) Interpolation (Using...
-
Read the case study "Southwest Airlines," found in Part 2 of your textbook. Review the "Guide to Case Analysis" found on pp. CA1 - CA11 of your textbook. (This guide follows the last case in the...
-
Managing Scope Changes Case Study Scope changes on a project can occur regardless of how well the project is planned or executed. Scope changes can be the result of something that was omitted during...
-
Smart housing Inc. is negotiating a deal to build a house. The owner wants to start in early spring when the weather begins to moderate and build through the summer into the fall. The completion time...
-
A cold plate is an active cooling device that is attached to a heat-generating system in order to dissipate the heat while maintaining the system at an acceptable temperature. It is typically...
-
Write a method maxMagnitude() with three integer parameters that returns the largest magnitude value. Use the method in the main program that takes three integer inputs and outputs the largest...
-
Suppose that in the double stochastic Simplico gold mine example the real probability of an up move in gold is 6 and the real probability of an up move in the short rate is .7. Suppose also that gold...
-
The Hydro-Electric Company (HEC) has three sources of power. A small amount of hydroelectric power is generated by damming wild and scenic rivers: a second source of power comes from burning coal,...
-
Nora Incorporated sells a single product for $22. Variable costs include $8.58 for each unit plus a 8% sales commission. Fixed costs are $155,290 per month. Required: a. What is the contribution...
-
Alan and Angel Young are both 36 years old. Mr. Young recently accepted a new job making $93,000 a year and Mrs. Young is currently unemployed. The Youngs have two children (ages 4 and 2), a dog, and...
-
Questions are raised about the low profile of facilities management in professional social networks where it is noted that facilities managers are frequently not represented at the highest levels in...
-
The General Social Survey asked a sample of adults how many siblings (brothers and sisters) they had \((X)\) and also how many children they had \((Y)\). We show results for those who had no more...
-
If two identical first order stable low pass filters are cascaded non-interactively, then the unit step response of the composite filter will be (a) critically damped (b) overdamped (c) underdamped...
-
Write the negation of each statement. a. The processor is fast but the printer is slow. b. The processor is fast or else the printer is slow. c. If the processor is fast, then the printer is slow. d....
-
A closed-loop system is shown below. The noise transfer function \(\frac{C_{n}(s)}{N(s)}\left[C_{n}(s)= ight.\) output corresponding to noise input \(\mathrm{N}(\mathrm{s})\) ] is approximately: (a)...
-
The probability that a bolt meets a strength specification is 0.87 . What is the probability that the bolt does not meet the specification?
-
us pleted pleted (5%) Problem 8: Suppose you have a 8.75 pF capacitor. Find the charge stored when 6.5 V is applied to it in pC. Q-
-
Determine the values of the given trigonometric functions directly on a calculator. The angles are approximate. tan 0.8035
-
Suppose that we want to compute the geometric mean of a list of positive values. To compute the geometric mean of k values, multiply them all together and then compute the kth root of the value. For...
-
Modify the Bouncing Ball example from Listing 9.18, except instead of animating a red circle, animate an image of your choice. Listing 9.18 import javafx.application.Application; import...
-
Repeat the previous exercise, but find the second word in the string. Previous exercise Write some Java statements that use the String methods indexOf and substring to find the first word in a...
-
In testing a claim about a population mean, a larger z test statistic always results in a larger P-value. Decide whether the statement makes sense (or is clearly true) or does not make sense (or is...
-
In testing the claim that the mean IQ score of statistics students is greater than 100, the alternative hypothesis is expressed as > 100. Decide whether the statement makes sense (or is clearly...
-
A handy mnemonic for interpreting the P-value in a hypothesis test is this: If the P (value) is low, then the null must go.
Study smarter with the SolutionInn App