Computer scienceFundamentalsEssentialsSoftware constructionDesign patternsStructural design patterns

Decorator pattern

Decorator diagram

Report a typo

Here we have an example of a decorator pattern class diagram.

For the ComputerParts class, method addPart() prints "Adding CPU, Motherboard, PowerSupply, RAM". For wrappers, we add additional words( SSD -"SSD", GPU -"GPU", Peripherals-"Mouse and keyboard").

We need to print the text "Adding CPU, Motherboard, PowerSupply, RAM, SSD, GPU". How should we call our objects in code?

decorator pattern class diagram for computer assembling

Select one option from the list
___

Create a free account to access the full topic