public static void Main() { //Your system could have bulk of builders var tripBuilder = new TripLaptopBuilder(); var gamingBuilder = new GamingLaptopBuilder(); var shopForYou = new BuyLaptop(); //director shopForYou.SetLaptopBuilder(gamingBuilder); //Customer answered that he wants to play shopForYou.ConstructLaptop(); Laptop laptop = shopForYou.GetLaptop(); //just get what he wants Console.WriteLine(laptop.ToString()); shopForYou.SetLaptopBuilder(tripBuilder); shopForYou.ConstructLaptop(); var tripLaptop = shopForYou.GetLaptop(); Console.WriteLine(tripLaptop.ToString()); }
static void Main(string[] args) { var tripLaptopBuilder = new TripLaptopBuilder(); var gamingLaptopBuilder = new GamingLaptopBuilder(); var shopForYou = new BuyLaptop(); shopForYou.SetLaptopBuilder(gamingLaptopBuilder); shopForYou.ConstructorLaptop(); Laptop laptop = shopForYou.GetLaptop(); Console.WriteLine(laptop.ToString()); shopForYou.SetLaptopBuilder(tripLaptopBuilder); shopForYou.ConstructorLaptop(); Laptop laptop2 = shopForYou.GetLaptop(); Console.WriteLine(laptop2.ToString()); Console.ReadLine(); }