Please inspect the following design and answer the following question. class Apartment { protected int squareFootage:...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Please inspect the following design and answer the following question. class Apartment { protected int squareFootage: protected int numberOfBedrooms. } public int getBedroom Count() { return numberOfBedrooms; } public void addBedRoom (int saft) { this square footage = saft; this numberOfBedrooms += 1; } } class PenthouseSuite extends Apartment { public PenthouseSuite() { this numberOfBedrooms = 4; } class Studio extends Apartment { public Studio() { this numberOfBedrooms = 0; } public void addBedRoom (int saft) { this square footage = saft: } a. Which SOLID design principle does the above design violate? (3pts) b. Illustrate with an example code to show how the above design can cause issues. (7pts) Please inspect the following design and answer the following question. class Apartment { protected int squareFootage: protected int numberOfBedrooms. } public int getBedroom Count() { return numberOfBedrooms; } public void addBedRoom (int saft) { this square footage = saft; this numberOfBedrooms += 1; } } class PenthouseSuite extends Apartment { public PenthouseSuite() { this numberOfBedrooms = 4; } class Studio extends Apartment { public Studio() { this numberOfBedrooms = 0; } public void addBedRoom (int saft) { this square footage = saft: } a. Which SOLID design principle does the above design violate? (3pts) b. Illustrate with an example code to show how the above design can cause issues. (7pts)
Expert Answer:
Answer rating: 100% (QA)
The image contains a code snippet displaying a class inheritance hierarchy in an objectoriented programming design It shows a base class Apartment wit... View the full answer
Related Book For
Data Structures and Algorithms in Java
ISBN: 978-1118771334
6th edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Posted Date:
Students also viewed these programming questions
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
Illustrate with an example how sole traders and partners are taxed in Australia. How does this compare to Australian company tax?
-
discuss the benefits and challenges of the employee job performance evaluation process as it relates to the ratings of an individual. For example, if an employer uses a standard Likert Scale (1...
-
On a TV screen, red, green, and blue spots of fluorescent materials are illuminated at a variety of relative intensities to produce a full spectrum of colors. What dots are activated to produce...
-
Springfield Bank is evaluating Creek Enterprises, which has requested a $4,000,000 loan, to assess the firms financial leverage and financial risk. On the basis of the debt ratios for Creek, along...
-
In a differential wheel and axle, the diameter of the larger axle is 250 mm and that of the smaller 225 mm. The diameter of effort wheel is 500 mm. Find the velocity ratio. If an effort of 150 N...
-
Partial adjusted trial balance data for Wilder Company is presented in BE3-9. The balance in Owners Capital is the balance as of January 1. Prepare an owners equity statement for the year assuming...
-
Half a liter of gas in an air conditioner is initially at a temperature of 25 degrees Celsius and 2.0 atm of pressure. The volume of the gas is rapidly expanded to 2 L and the pressure of the gas...
-
Skylar and Walter Black have been married for 25 years. They live at 883 Scrub Brush Street, Apt. 52B, Las Vegas, NV 89125. Skylar is a stay-at-home parent and Walt is a high school teacher. Skylars...
-
Given the following code, what would be the output? class Dog: definit__(self, name): self.name = name def walk(self): return "You and" + self.name + walk down the trail." def speak(self): 11 return...
-
Kingbird Company purchased Machine #201 on May 1, 2025. The following information relating to Machine #201 was gathered at the end of May. Price Credit terms Freight-in Preparation and installation...
-
Job number A9028 requires $300 of direct materials and $400 of direct labour which is paid at the rate of $8 per hour. Production overheads are applied at a rate of $26 per direct labour hour....
-
Sandhill Manufacturing Corp. decided to expand further by purchasing the net assets of Blossom Manufacturing Corp. Blossom's statement of financial position at December 31, 2023 follows. BLOSSOM...
-
Complete the payroll register for this pay period and update the Employee Earnings Record form for each employee with the corresponding information. The Step-2 of Form W-4 is unchecked. The amount...
-
A lot of people do not know the difference between Advertising and Public Relations. What are three key differences between advertising and public relations? If you were to choose one of these...
-
If you earn 10% per year on your investments but pay 35% in taxes on all of your investment returns, then what is your annual after-tax return? * Make sure to input all percentage answers as numeric...
-
Parkin Industries, a U.S. company, acquired a wholly-owned subsidiary, located in Italy, at the beginning of the current year, for 200,000. The subsidiary's functional currency is the euro. The...
-
In Section 7.5.3, we demonstrated how the Collections.shuffle method can be adapted to shuffle a reference-type array. Give a direct implementation of a shuffle method for an array of int values. You...
-
When a share of common stock of some company is sold, the capital gain (or, sometimes, loss) is the difference between the shares selling price and the price originally paid to buy it. This rule is...
-
Implement the B-tree data structure, assuming a block size of 1024 and integer keys. Test the number of disk transfers needed to process a sequence of map operations.
-
Explain how the financial manager might use industry norms in the design of the companys financing mix.
-
You have developed the following income statement for Sing-Tel Corporation. It represents the most recent years operations, which ended yesterday. Your supervisor in the controllers office has just...
-
Footwear, Inc. manufactures a complete line of mens and womens formal shoes for independent merchants. The average selling price of its finished product is \($85\) per pair. The variable cost for...
Study smarter with the SolutionInn App