Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Assume that you have opened a modern 'Icecream Bar' in front of the NSU main gate. [30] In your Icecream Bar, different flavors of

image text in transcribed

1. Assume that you have opened a modern 'Icecream Bar' in front of the NSU main gate. [30] 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 hasSprinkles:boolean - hasCaramelSauce: boolean + Icecream (...) + getPrice (): double + getHasCandy (: boolean + getHas Sprinkles (): boolean + getHasCaramelSauce (): boolean Chocolatelcecream 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

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

Step: 3

blur-text-image

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

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

What results did this produce?

Answered: 1 week ago