Decorator pattern
…of other instances of the same class, provided some groundwork is done at design time. This is achieved by designing a new Decorator class that wraps the original class. This wrapping could be achieved by the following sequence of steps: Subclass the original Component class into a Decorator class…