Esempio n. 1
0
        static void Main(string[] args)
        {
            Manufacturer newManufacturer = new Manufacturer();

            IPhoneBuilder phoneBuilder = new AndroidPhoneBuilder();

            newManufacturer.Construct(phoneBuilder);
            Console.WriteLine("A new Phone built:\n\n{0}", phoneBuilder.Phone().ToString());

            phoneBuilder = new WindowsPhoneBuilder();
            newManufacturer.Construct(phoneBuilder);
            Console.WriteLine("A new Phone built:\n\n{0}", phoneBuilder.Phone().ToString());
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Manufacturer  manufacturer = new Manufacturer();
            IPhoneBuilder phone        = null;

            phone = new AndroidPhoneBuilder();
            manufacturer.Construct(phone);

            Console.WriteLine("Phone Built with specifications - " + phone.Phone.ToString());

            phone = new WindowsPhoneBuilder();
            manufacturer.Construct(phone);

            Console.WriteLine("Phone built with specifications - " + phone.Phone.ToString());
            Console.ReadLine();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            // Lets create the Director first
            Manufacturer newManufacturer = new Manufacturer();
            // Lets have the Builder class ready
            IPhoneBuilder phoneBuilder = null;

            // Now let us create an android phone
            phoneBuilder = new AndroidPhoneBuilder();
            newManufacturer.Construct(phoneBuilder);
            Console.WriteLine("A new Phone built:\n\n{0}", phoneBuilder.Phone.ToString());

            // Now let us create a Windows Phone
            phoneBuilder = new WindowsPhoneBuilder();
            newManufacturer.Construct(phoneBuilder);
            Console.WriteLine("A new Phone built:\n\n{0}", phoneBuilder.Phone.ToString());
        }
        static void Main(string[] args)
        {
            var house = new HouseBuilder()
                        .Area(500)
                        .NumberOfRooms(4)
                        .HasGarage(true)
                        .Build();


            //More info: https://www.codeproject.com/Articles/470476/Understanding-and-Implementing-Builder-Pattern-in
            //Slightly modified version of above link

            // Lets create the Director first
            var manufacturer = new Manufacturer();

            // Now let us create an android phone
            IPhoneBuilder androidPhoneBuilder = new AndroidPhoneBuilder();
            var           androidPhone        = manufacturer.Construct(androidPhoneBuilder);

            // Now let us create a Windows Phone
            IPhoneBuilder windowsPhoneBuilder = new WindowsPhoneBuilder();
            var           windowsPhone        = manufacturer.Construct(windowsPhoneBuilder);
        }