Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help me with question e Examine Listing 1 and answer the following questions. Each question is independent of the others and assumes, as a

image text in transcribed

image text in transcribed

please help me with question e

Examine Listing 1 and answer the following questions. Each question is independent of the others and assumes, as a starting point, the code that is given in Listing 1. d) Is the use of inheritance a good design decision in this situation? Explain your answer. (4 marks) e) Refactor the class hierarchy to use composition instead of inheritance. The client code, which is given in Listing 2 and uses the existing hierarchy, must be able to use the refactored code without having to be modified. (8 marks) auto b = Book:"The Great Gatsby", "F.Scott Fitzgerald", 4\}; cout b.author() endl; auto d= DVD { "Star Wars: Episode V - The Empire Strikes", 124, 3\}; cout d. runtime() endl; b. borrowItem(); d. borrowItem(); b. returnItem(); cout d.title() ": " "available copies: " d. availableCopies() endl; cout b.title() ": " "available copies: " b.availableCopies() endl; Examine Listing 1 and answer the following questions. Each question is independent of the others and assumes, as a starting point, the code that is given in Listing 1. d) Is the use of inheritance a good design decision in this situation? Explain your answer. (4 marks) e) Refactor the class hierarchy to use composition instead of inheritance. The client code, which is given in Listing 2 and uses the existing hierarchy, must be able to use the refactored code without having to be modified. (8 marks) auto b = Book:"The Great Gatsby", "F.Scott Fitzgerald", 4\}; cout b.author() endl; auto d= DVD { "Star Wars: Episode V - The Empire Strikes", 124, 3\}; cout d. runtime() endl; b. borrowItem(); d. borrowItem(); b. returnItem(); cout d.title() ": " "available copies: " d. availableCopies() endl; cout b.title() ": " "available copies: " b.availableCopies() endl

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

Accounting for Governmental and Nonprofit Entities

Authors: Earl R. Wilson, Jacqueline L Reck, Susan C Kattelus

16th Edition

78110939, 978-0078110931

More Books

Students also viewed these Accounting questions

Question

What are the features of Management?

Answered: 1 week ago

Question

Briefly explain the advantages of 'Management by Objectives'

Answered: 1 week ago

Question

Explain the various methods of job evaluation

Answered: 1 week ago