I'm trying to get my head around design patterns. I think they may be one step too advanced in my programming abilities as I am struggling quite a bit with them, however my university assignment is to apply them. So here I am.
I am going through the example of the Decorator Pattern from the Head First book. This is the example:
As you can see in the diagram, the CondimentDecorator has the IS-A and HAS-A relationship with Beverage. However, here is the code they write for the CondimentDecorator and one of the condiments, Mocha:
In the CondimentDecorator class the only thing that it contains is a method getDescription.
It's the Mocha class that contains instantiates the Beverage class AND calls getDescription.
So doesn't this mean that it's the Mocha class that has a IS-A and a HAS-A relationship?


