static void Main(string[] args)
        {
            LaptopBuilder gamingLaptopBuilder = new GamingLaptopBuilder();
            BuyLaptop     buyLaptop           = new BuyLaptop();

            buyLaptop.SetLaptopBuilder(gamingLaptopBuilder);
            buyLaptop.ConstructLaptop();
            var laptop = buyLaptop.GetLaptop();

            Console.WriteLine($"{laptop.Memory}, {laptop.MonitorResolution}, {laptop.Battery}, {laptop.HDD}, {laptop.Processor}");
            Console.ReadKey();
        }
Ejemplo n.º 2
0
        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());
        }
Ejemplo n.º 3
0
        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();
        }