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