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

 Exercise1: Propose the java code associated to the below class diagram

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!