Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise1: Propose the java code associated to the below class diagram using the decorator pattern. The method getDescription() returns Tea for class Tea or Coffee

image text in transcribed

Exercise1: Propose the java code associated to the below class diagram using the decorator pattern. The method getDescription() returns "Tea" for class Tea or Coffee class Coffee. For the decorators, this method will add the decoration to the original object. The method cost() returns each time the cost of the obtained product. The private methods inside the decorators return the specific cost of the decoration and is used to calculate the global cost. Drink -name:String -price:Double +getDescription(): String +cost(): Double drink Tea Coffee +getDescription : String +cost(): Double +getDescription(): String +cost(): Double Drink Decorator +getDescription(): String +cost(): Double Cinnamon Decorator Mint Decorator Cream Decorator +cost(): Double -addCream(): Double +getDescription(): String +cost(): Double -addCinnamon(): Double +getDescription(): String +cost(): Double -addMint(): Double +getDescription(): String

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

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions