Question: Write the required Java code to implement only the two classes BreadDecorator and CheeseDecorator using the decorator pattern. The GetCost() returns the products price. It
- Write the required Java code to implement only the two classes BreadDecorator and CheeseDecorator using the decorator pattern. The GetCost() returns the products price. It can be the original price or global price after decoration (after adding cheese or potato). The methods AddCheese() and AddPotato() return the decorations price. The GetDescription() returns the description of the final product (Example: French Bread with cheese).

Bread -description : String -cost : Double +GetDescription() :String +GetCost(): Double FrenchBread +GetDescription():String +GetCost(): Double Arabic Bread +GetDescription():String +GetCost(): Double BreadDecorator +GetDescription():String +GetCost(): Double Cheese Decorator +GetDescription():String +GetCost(): Double -AddCheese(): Double Potato Decorator +GetDescription():String +GetCost(): Double -AddPotato() : Double
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
