Composite Pattern
The Composite Design pattern allows a client object to treat both single components and collections of components identically.
The way we can think of composite pattern is that, there is some sort of a component [all most an interface]. Which comes in 2…