Answered step by step
Verified Expert Solution
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
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started