Composite design pattern.
Background – Before we jump into composite design pattern first let’s focus on whole-part relationship. What is whole-part relationship? When an object contains (or holds) another object in it , we say it is a whole-part relationship. types of whole-part relationship – There are two kind of whole-pert relationship – a. Composition b. Aggregation Composition – If you destroy whole part will also gets destroyed. Or if you delete whole object part object will be deleted. For example – There is a single room constructed by 4 walls like it is mentioned at below image. If we blast or destroy room all 4 walls will be destroyed. Here walls are part object and whole is room object. Aggregation – Destroying whole will not destroy part. Or deleting whole object will not delete part object. For example – Consider 2 rooms with 7 walls where 1 wall is common among them same as mentioned at below. Now if I destroy room 1, r