Question: Correct answer only please. [30] 1. Assume that you have opened a modern Icecream Bar' in front of the NSU main gate. In your Icecream
Correct answer only please. ![Correct answer only please. [30] 1. Assume that you have opened a](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66f93493353d9_95466f93492b8f94.jpg)
[30] 1. Assume that you have opened a modern "Icecream Bar' in front of the NSU main gate. In your Icecream Bar, different flavors of Ice cream are available along with a range of choices of toppings. Customers can have any flavors with their choice of toppings. You want to build an App for customers to order their flavor and choose toppings. The App should calculate the price according to the ice cream flavor and toppings. Each flavor and toppings have a different unit cost. Initially, you have designed the following class diagram for the App mentioned above. Icecream -name: String - hasCandy boolean has Sprinkles boolean hasCaramelsauce: boolean + Icecream (...) + getPrice (): double + getHasCandy (): boolean getHas Sprinkles(): boolean + getHasCaramelsauce (): boolean 4 Chocolate cecream Vanillalcecream getPrice ( double getPrice (), double Page 1 of 4 13 January 2021 However, this design has the following problems. Price changes in toppings will lead to alternation in the existing code of getPrice(). New toppings will force adding new variables and methods in the Icecream class and changing calculation accordingly. Some toppings may not be appropriate for some ice cream flavors, yet the subclass inherits them. Answer the following questions. a) Apply the Decorator design pattern to solve the problems mentioned above. After applying the Decorator design pattern, draw the class diagram and justify your answer. (20 points) b) Explain how your design satisfies the "Open-Closed Principle". (10 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
