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 2.50-F capacitor is charged to 746 V and a 6.80-F capacitor is charged to 562V. These capacitors are then disconnected from their batteries. Next the positive plates are connected to each other and...
-
Planning: Assessing Audience Needs; Media Skills: Mobile Using a computer or full-sized tablet, visit the website of any well-known company and review its About or About Us page. Identify three ways...
-
Pentland Shoe Company acquired 75 percent of Sketchers Inc.'s common stock on January 2, 2014 for \($180\) million. The fair value of the 25 percent noncontrolling interest was \($50\) million at the...
-
All That Blooms provides environmentally friendly lawn services for homeowners. Its operating costs are as follows. Depreciation ......... $1,400 per month Advertising ........ $200 per month...
-
Statement of retained earnings Hayes Enterprises began 2019 with a retained eamings balance of $940,000. During 2019, the firm earned $372.000 after taxes. From this amount, preferred stockholders...
-
Sanyu Sony started a new business and completed these transactions during December. December 1 Sanyu Sony transferred $68,700 cash from a personal savings account to a checking account in the name of...
-
Marks Music is a store that buys and sells musical instruments and uses a perpetual inventory system. Transactions for the business are shown below: Nov. 2 Purchased two electric guitars from Fender...
-
The Front Door Corp. has 149,440 shares of common stock outstanding. In 2025, the company reports income from continuing operations before income tax of $1,228,000. Additional transactions not...
-
A Japanese investor can earn a 1 percent annual interest rate in Japan or about 3.5 percent per year in the United States. If the spot exchange rate YEN/USD is 101, what is the spot rate one-year...
-
4 in Assume W=your month + your day of birth =__ 31 lbs and d=2+(month of birth)/2 = Draw the free-body diagram of the shaft A-B-C, assuming the unbalanced torque to be resisted by the support at C....
-
John 3:16, Is Consideration present? Identify the consideration, Would God's contract with believers be enforceable under the law of contracts? Explain why? State the Question to be answered. State...
-
Formative Exercise Exercise Description: Using concepts, issue, and skills you learnt form the readings, PowerPoints notes, the Business Case provided in the next few slides, to address the questions...
-
On December 31, Year 7, Pepper Company, a public company, agreed to a business combination with Salt Limited, an unrelated private company. Pepper issued 82 of its common shares for all 50 of the...
-
Differentiate. y = ln(3x + 1) ln(5x + 1)
-
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...
-
Cruse Corporation started operations on January 1,2020 . Taxable income from the tax return is \(\$ 2,850,000\). Income tax rate is \(25 \%\). There were no beginning balances in deferred tax...
-
For 2020, Raleigh Corporation had taxable income of \(\$ 100,000\) and an income tax rate of \(25 \%\). Raleigh had a \(\$ 75,000\) credit balance in its Deferred Tax Liability account. This credit...
-
Listed below are ten separate situations. For each item indicates whether the difference is (1) temporary creating a deferred tax asset or a deferred tax liability or (2) permanent. Item 1. Pension...
Study smarter with the SolutionInn App