Question: 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


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
Get step-by-step solutions from verified subject matter experts
