using System.Collections.Generic;
public interface IComponent
public class Leaf : IComponent
public int Broi { get; set; }
public string Name { get; set; }
public Leaf(string name, int broi)
this.Broi = broi; this.Name = name;
public void DisplayPrice()
Console.WriteLine(Name + ": " + Broi);
public class Composite : IComponent
public string Name { get; set; }
List<IComponent> components = new List<IComponent>();
public Composite(string name)
public void AddComponent(IComponent component)
components.Add(component);
public void DisplayPrice()
foreach (var item in components)
public static void Main(string[] args)
IComponent dres = new Leaf("dres",10 );
IComponent sweaters = new Leaf("sweaters", 7);
IComponent pants = new Leaf("pants", 9);
IComponent swimwear = new Leaf("swimwear", 2);
Composite clothing = new Composite("clothing has");
Composite Women = new Composite("-women");
Composite men = new Composite("-men");
Composite children = new Composite("-children");
clothing.AddComponent(Women);
Women.AddComponent(dres);
Women.AddComponent(sweaters);
Women.AddComponent(pants);
Women.AddComponent(swimwear);
clothing.AddComponent(men);
clothing.AddComponent(children);