static void Main(string[] args)
        {
            VehicleBuilder builder;

            // Create shop with vehicle builders

            Shop shop = new Shop();

            // Construct and display vehicles

            builder = new ScooterBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            // Wait for user

            Console.ReadKey();
        }
Esempio n. 2
0
        public void TestCarBuilder()
        {
            var shop = new Shop();

            VehicleBuilder builder = new ScooterBuilder();

            shop.Construct(builder);
            var scooter = builder.Vehicle.Show(true);

            Assert.AreEqual(scooter["frame"], "Scooter Frame");
            Assert.AreEqual(scooter["engine"], "50 cc");
            Assert.AreEqual(scooter["wheels"], "2");
            Assert.AreEqual(scooter["doors"], "0");

            builder = new CarBuilder();
            shop.Construct(builder);
            var car = builder.Vehicle.Show(true);

            Assert.AreEqual(car["frame"], "Car Frame");
            Assert.AreEqual(car["engine"], "2500 cc");
            Assert.AreEqual(car["wheels"], "4");
            Assert.AreEqual(car["doors"], "4");

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            var motor = builder.Vehicle.Show(true);

            Assert.AreEqual(motor["frame"], "MotorCycle Frame");
            Assert.AreEqual(motor["engine"], "500 cc");
            Assert.AreEqual(motor["wheels"], "2");
            Assert.AreEqual(motor["doors"], "0");
        }
Esempio n. 3
0
            /// <summary>
            /// Entry point into console application.
            /// </summary>
            public static void Main222()
            {
                prodA obja = new prodA();
                   var  obja1 = new productclass();
                  // obja1 = obja;
                obja.print();
                obja1.print();
                VehicleBuilder builder;

                // Create shop with vehicle builders
                Shop shop = new Shop();

                // Construct and display vehicles
                builder = new ScooterBuilder();
                shop.Construct(builder);
                builder.Vehicle.Show();

                builder = new CarBuilder();
                shop.Construct(builder);
                builder.Vehicle.Show();

                builder = new MotorCycleBuilder();
                shop.Construct(builder);
                builder.Vehicle.Show();

                // Wait for user
                Console.ReadKey();
            }
    void Start()
    {
        // Instantiate the director and builders
        ShopForeman shopForeman = new ShopForeman();
        CarBuilder carBuilder = new CarBuilder();
        MotorCycleBuilder motorCycleBuilder = new MotorCycleBuilder();
        ScooterBuilder scooterBuilder = new ScooterBuilder();

        // Make the products
        shopForeman.Construct(carBuilder);
        shopForeman.Construct(motorCycleBuilder);
        shopForeman.Construct(scooterBuilder);

        // Get the vehicles and do stuff with them
        Vehicle car = carBuilder.vehicle;
        car.parent.transform.position = new Vector3(-6f, 0, 0);
        Debug.Log(car.GetPartsList());
        
        Vehicle motorCycle = motorCycleBuilder.vehicle;
        motorCycle.parent.transform.position = new Vector3(6f, 0, 0);
        Debug.Log(motorCycle.GetPartsList());

        
        Vehicle scooter = scooterBuilder.vehicle;
        scooter.parent.transform.localScale *= 0.5f;
        Debug.Log(scooter.GetPartsList());
        
    }
Esempio n. 5
0
    void Start()
    {
        // Instantiate the director and builders
        ShopForeman       shopForeman       = new ShopForeman();
        CarBuilder        carBuilder        = new CarBuilder();
        MotorCycleBuilder motorCycleBuilder = new MotorCycleBuilder();
        ScooterBuilder    scooterBuilder    = new ScooterBuilder();

        // Make the products, the vehicles.
        shopForeman.Construct(carBuilder);
        shopForeman.Construct(motorCycleBuilder);
        shopForeman.Construct(scooterBuilder);

        // Get the vehicles and access their methods.
        Vehicle car = carBuilder.vehicle;

        Debug.Log(car.GetPartsList());

        Vehicle motorCycle = motorCycleBuilder.vehicle;

        Debug.Log(motorCycle.GetPartsList());

        Vehicle scooter = scooterBuilder.vehicle;

        Debug.Log(scooter.GetPartsList());


        // These calls don't have anything to do with the pattern.
        // They are simply here to make our visual display of the vehicles
        // in the Unity scene look nice.
        car.parent.transform.position        = new Vector3(-6f, 0, 0);
        motorCycle.parent.transform.position = new Vector3(6f, 0, 0);
    }
Esempio n. 6
0
        private static void ShowBuilder()
        {
            Console.WriteLine("================================================");
            Console.WriteLine("Pattern code (Builder):");
            Director director = new Director();

            Builder b1 = new ConcreteBuilder1();
            Builder b2 = new ConcreteBuilder2();

            director.Construct(b1);
            Product p1 = b1.GetResult();

            p1.Show();

            director.Construct(b2);
            Product p2 = b2.GetResult();

            p2.Show();

            Console.WriteLine("Real code (Builder):");
            Shop shop = new Shop();

            VehicleBuilder builder = new ScooterBuilder();

            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();
        }
Esempio n. 7
0
            /// <summary>
            /// Entry point into console application.
            /// </summary>
            public static void Main222()
            {
                prodA obja  = new prodA();
                var   obja1 = new productclass();

                // obja1 = obja;
                obja.print();
                obja1.print();
                VehicleBuilder builder;

                // Create shop with vehicle builders
                Shop shop = new Shop();

                // Construct and display vehicles
                builder = new ScooterBuilder();
                shop.Construct(builder);
                builder.Vehicle.Show();

                builder = new CarBuilder();
                shop.Construct(builder);
                builder.Vehicle.Show();

                builder = new MotorCycleBuilder();
                shop.Construct(builder);
                builder.Vehicle.Show();

                // Wait for user
                Console.ReadKey();
            }
Esempio n. 8
0
        private void btnBuilder_Click(object sender, EventArgs e)
        {
            // ------------------------------------------------------------------------
            // Builder Pattern
            // https://dofactory.com/net/builder-design-pattern
            // Frequency of use: 3 - Medium low

            txtOutput.Text = "";

            VehicleBuilder builder;

            // Create shop with vehicle builders
            Shop shop = new Shop();

            // Construct and display vehicles
            builder = new ScooterBuilder();
            shop.Construct(builder);
            txtOutput.Text += builder.Vehicle.Show();

            builder = new CarBuilder();
            shop.Construct(builder);
            txtOutput.Text += builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            txtOutput.Text += builder.Vehicle.Show();
        }
    void Start()
    {
        // Instantiate the director and builders
        ShopForeman shopForeman = new ShopForeman();
        CarBuilder carBuilder = new CarBuilder();
        MotorCycleBuilder motorCycleBuilder = new MotorCycleBuilder();
        ScooterBuilder scooterBuilder = new ScooterBuilder();

        // Make the products, the vehicles.
        shopForeman.Construct(carBuilder);
        shopForeman.Construct(motorCycleBuilder);
        shopForeman.Construct(scooterBuilder);

        // Get the vehicles and access their methods.
        Vehicle car = carBuilder.vehicle;
        Debug.Log(car.GetPartsList());
        
        Vehicle motorCycle = motorCycleBuilder.vehicle;
        Debug.Log(motorCycle.GetPartsList());

        Vehicle scooter = scooterBuilder.vehicle;
        Debug.Log(scooter.GetPartsList());


        // These calls don't have anything to do with the pattern.
        // They are simply here to make our visual display of the vehicles
        // in the Unity scene look nice.
        car.parent.transform.position = new Vector3(-6f, 0, 0);
        motorCycle.parent.transform.position = new Vector3(6f, 0, 0);
    }
Esempio n. 10
0
        public void BuilderTest()
        {
            VehicleBuilder builder;

            // Create shop with vehicle builders

            Shop shop = new Shop();

            // Construct and display vehicles

            builder = new ScooterBuilder();
            shop.Construct(builder);
            Assert.IsTrue(builder.Vehicle.VehicleType == "Scooter");
            Assert.IsTrue(builder.Vehicle.Parts["frame"] == "Scooter Frame");
            Assert.IsTrue(builder.Vehicle.Parts["engine"] == "50 cc");
            Assert.IsTrue(builder.Vehicle.Parts["wheels"] == "2");
            Assert.IsTrue(builder.Vehicle.Parts["doors"] == "0");

            builder = new CarBuilder();
            shop.Construct(builder);
            Assert.IsTrue(builder.Vehicle.VehicleType == "Car");
            Assert.IsTrue(builder.Vehicle.Parts["frame"] == "Car Frame");
            Assert.IsTrue(builder.Vehicle.Parts["engine"] == "2500 cc");
            Assert.IsTrue(builder.Vehicle.Parts["wheels"] == "4");
            Assert.IsTrue(builder.Vehicle.Parts["doors"] == "4");

            builder = new MotorcycleBuilder();
            shop.Construct(builder);
            Assert.IsTrue(builder.Vehicle.VehicleType == "Motorcycle");
            Assert.IsTrue(builder.Vehicle.Parts["frame"] == "Motorcycle Frame");
            Assert.IsTrue(builder.Vehicle.Parts["engine"] == "500 cc");
            Assert.IsTrue(builder.Vehicle.Parts["wheels"] == "2");
            Assert.IsTrue(builder.Vehicle.Parts["doors"] == "0");
        }
Esempio n. 11
0
        public void Execute()
        {
            VehicleBuilderBase builder;

            Shop shop = new Shop();

            builder = new CarBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new ScooterBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();
        }
Esempio n. 12
0
        public static void Main()
        {
            var shop = new Shop();

            var carBuilder = new CarBuilder();

            shop.Construct(carBuilder);
            carBuilder.Vehicle.Show();

            var scooterBuilder = new ScooterBuilder();

            shop.Construct(scooterBuilder);
            scooterBuilder.Vehicle.Show();
        }
Esempio n. 13
0
        public static void Test()
        {
            Shop           shop = new Shop();
            VehicleBuilder b1   = new ScooterBuilder();
            VehicleBuilder b2   = new CarBuilder();
            VehicleBuilder b3   = new MotorCycleBuilder();

            shop.Construct(b1);
            b1.Vehicle.Show();

            shop.Construct(b2);
            b2.Vehicle.Show();

            shop.Construct(b3);
            b3.Vehicle.Show();
        }
        // GET: Build
        public ActionResult Index()
        {
            // create manufacturer
            Manufacturer manufacturer = new Manufacturer();

            // create builder
            ScooterBuilder scb = new ScooterBuilder();

            // creating bike by passing reference of scooter builder
            manufacturer.Construct(scb);

            // Geting the instance of bike, created by Construct method of manufacturer object.
            var b = scb.GetBike();

            return(View());
        }
Esempio n. 15
0
        internal static void Main()
        {
            VehicleBuilder builder;
            var            shop = new Shop();

            builder = new ScooterBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();
        }
Esempio n. 16
0
        static void Main()
        {
            var car = VehicleProducer.Build(CarBuilder.GetInstance());

            var motorCycle = VehicleProducer.Build(MotorCycleBuilder.GetInstance());

            var scooterBuilder = VehicleProducer.Build(ScooterBuilder.GetInstance());

            car = CarBuilder
                  .GetInstance()
                  .WithDoors()
                  .WithEngine()
                  .WithFrame()
                  .WithType()
                  .WithWheels()
                  .Build();
        }
Esempio n. 17
0
            /// <summary>
            /// Entry point into console application.
            /// </summary>
            public void Main()
            {
                VehicleBuilder builder;
                // Create shop with vehicle builders
                Shop shop = new Shop();

                // Construct and display vehicles
                builder = new ScooterBuilder();
                shop.Construct(builder);
                builder.Vehicle.Show();
                builder = new CarBuilder();
                shop.Construct(builder);
                builder.Vehicle.Show();
                builder = new MotorCycleBuilder();
                shop.Construct(builder);
                builder.Vehicle.Show();
            }
Esempio n. 18
0
        internal static void Main()
        {
            VehicleBuilder builder;
            var shop = new Shop();

            builder = new ScooterBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();
        }
        public void TestBuilderRealWorld()
        {
            var shop = new Shop();

            VehicleBuilder builder = new ScooterBuilder();

            shop.Construct(builder);
            builder.GetVehicle.Show();

            builder = new CarBuilder();
            shop.Construct(builder);
            builder.GetVehicle.Show();

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            builder.GetVehicle.Show();
        }
        public static void Main()
        {
            //Builder
            VehicleBuilder builder;

            //Create ConcreteBuilder and Execute Build
            builder = new ScooterBuilder();
            Shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            Shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            Shop.Construct(builder);
            builder.Vehicle.Show();
        }
Esempio n. 21
0
        public void RealWorldTest()
        {
            Shop shop = new Shop();

            VehicleBuilder builder;

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            builder.GetVehicleInstance().Show();

            builder = new CarBuilder();
            shop.Construct(builder);
            builder.GetVehicleInstance().Show();

            builder = new ScooterBuilder();
            shop.Construct(builder);
            builder.GetVehicleInstance().Show();
        }
Esempio n. 22
0
    void Start()
    {
        VehicleBuilder _VehicleBuilder;

        Shop _shop = new Shop();

        _VehicleBuilder = new ScooterBuilder();
        _shop.Construct(_VehicleBuilder);
        _VehicleBuilder.Vehicle.Show();

        _VehicleBuilder = new MotorCycleBuilder();
        _shop.Construct(_VehicleBuilder);
        _VehicleBuilder.Vehicle.Show();

        _VehicleBuilder = new CarBuilder();
        _shop.Construct(_VehicleBuilder);
        _VehicleBuilder.Vehicle.Show();
    }
Esempio n. 23
0
        public static void Main()
        {
            // We can choose concrete constructor (director)
            IVehicleConstructor constructor = new VehicleConstructor();

            // And we can choose concrete builder
            VehicleBuilder builder = new ScooterBuilder();
            constructor.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            constructor.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            constructor.Construct(builder);
            builder.Vehicle.Show();
        }
Esempio n. 24
0
        public BuilderPattern()
        {
            VehicleBuilder _builder;

            var shop = new Shop();

            _builder = new ScooterBuilder();
            shop.Construct(_builder);
            _builder.Vehicle.show();

            _builder = new MotorCycleBuilder();
            shop.Construct(_builder);
            _builder.Vehicle.show();

            _builder = new CarBuilder();
            shop.Construct(_builder);
            _builder.Vehicle.show();
        }
        public static void SecondDemo()
        {
            VehicleConstructor constructor = new VehicleConstructor();

            // And we can choose concrete builder
            VehicleBuilder builder = new ScooterBuilder();

            constructor.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            constructor.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            constructor.Construct(builder);
            builder.Vehicle.Show();
        }
Esempio n. 26
0
        static void Main(string[] args)
        {
            VehicleBuilder builder;
            Shop           shop = new Shop();

            builder = new ScooterBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();
            Console.ReadKey();
        }
Esempio n. 27
0
        static void Main(string[] args)
        {
            IBuilder b1 = new ScooterBuilder("Death");
            IBuilder b2 = new ChoopaChupsBuilder("Petya");

            Director dir = new Director();

            dir.Build(b1);
            dir.Build(b2);

            Console.WriteLine(b1.Product);

            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine(b2.Product);

            Console.ReadKey();
        }
Esempio n. 28
0
        static void Main(string[] args)
        {
            VehicleBuilder vehicleBuilder;
            var            factory = new Factory();

            vehicleBuilder = new ScooterBuilder();
            factory.Construct(vehicleBuilder);
            vehicleBuilder.vehicle.Show();

            vehicleBuilder = new MotorCycleBuilder();
            factory.Construct(vehicleBuilder);
            vehicleBuilder.vehicle.Show();

            vehicleBuilder = new CarVehicleBuilder();
            factory.Construct(vehicleBuilder);
            vehicleBuilder.vehicle.Show();

            Console.ReadKey();
        }
Esempio n. 29
0
        public override void buildProduct()
        {
            VehicleBuilder builder;

            // Create shop with vehicle builders
            VehicleShop shop = new VehicleShop();

            // Construct and display vehicles
            builder = new ScooterBuilder();
            Vehicle Scooter = shop.Construct(builder);
            Scooter.Show();

            builder = new CarBuilder();
            Vehicle Car = shop.Construct(builder);
            Car.Show();

            builder = new MotorCycleBuilder();
            Vehicle MotorCycle = shop.Construct(builder);
            MotorCycle.Show();
        }
Esempio n. 30
0
        public static void Main()
        {
            VehicleBuilder builder;

            // We can choose concrete constructor (director)
            var constructor = new VehicleConstructor();

            // And we can choose concrete builder
            builder = new ScooterBuilder();
            constructor.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            constructor.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            constructor.Construct(builder);
            builder.Vehicle.Show();
        }
Esempio n. 31
0
        public static void Execute()
        {
            VeiculoBuilder builder;

            // Cria uma montadora com veiculos builders (construtores de veículos)
            var shop = new Montadora();

            // Constroi e exible os veículos
            builder = new ScooterBuilder();
            shop.Construct(builder);
            builder.Veiculo.Show();

            builder = new CarroBuilder();
            shop.Construct(builder);
            builder.Veiculo.Show();

            builder = new MotocicletaBuilder();
            shop.Construct(builder);
            builder.Veiculo.Show();
        }
Esempio n. 32
0
        static void Main(string[] args)
        {
            //We cabn choose concrete constructor (director)
            IVehicleConstructor director = new VehicleConstructor();

            //And we can choose concrete builder
            VehicleBuilder builder = new CarBuilder();

            director.Construct(builder);
            builder.Vehicle.Show();

            director = new VehicleConstructor();
            builder  = new ScooterBuilder();
            director.Construct(builder);
            builder.Vehicle.Show();

            director = new VehicleConstructor();
            builder  = new MotorCycleBuilder();
            director.Construct(builder);
            builder.Vehicle.Show();
        }
        static void Main(string[] args)
        {
            #region Ordinary Builder

            var            shop = new VehicleClass();
            VehicleBuilder builder;

            builder = new ScooterBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            #endregion

            #region Fluent Builder

            var pizzaPepOlives = new PizzaBuilder(Size.Medium)
                                 .AddSauce()
                                 .AddCheese(Cheese.Provolone)
                                 .AddPepperoni()
                                 .AddOlives()
                                 .Build();

            var pizzaOlivesMushrooms = new PizzaBuilder()
                                       .AddSauce()
                                       .AddCheese()
                                       .AddOlives()
                                       .AddMushrooms()
                                       .Build();

            #endregion
        }
Esempio n. 34
0
        /// <summary>
        /// Entry point into console application.
        /// </summary>
        public Class1()
        {
            VehicleBuilder builder;

            // Create shop with vehicle builders
            Shop shop = new Shop();

            // Construct and display vehicles
            builder = new ScooterBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            shop.Construct(builder);
            builder.Vehicle.Show();

            // Wait for user
            Console.ReadKey();
        }
Esempio n. 35
0
        public static void BuilderRealWorld()
        {
            VehicleBuilder builder;

            // Create shop with vehicle builders
            var shop = new Shop();

            // Construct and display vehicles
            builder = new ScooterBuilder();
            Log.WriteLine("\n{0} has Created", builder.GetType().Name);
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new CarBuilder();
            Log.WriteLine("\n{0} has Created", builder.GetType().Name);
            shop.Construct(builder);
            builder.Vehicle.Show();

            builder = new MotorCycleBuilder();
            Log.WriteLine("\n{0} has Created", builder.GetType().Name);
            shop.Construct(builder);
            builder.Vehicle.Show();
        }
Esempio n. 36
0
        static void Main()
        {
            IVehicleBuilder builder;
            Shop            shop = new Shop();

            builder = new ScooterBuilder();
            shop.Construct(builder);
            var scooter = builder.GetVehicle();

            scooter.Show();

            builder = new CarBuilder();
            shop.Construct(builder);
            Vehicle car = builder.GetVehicle();

            car.Show();

            builder = new MotorcycleBuilder();
            shop.Construct(builder);
            var motorcycle = builder.GetVehicle();

            motorcycle.Show();
        }
Esempio n. 37
0
  public static void Main( string[] args )
  {
    // Create shop with vehicle builders
    Shop shop = new Shop();
    VehicleBuilder b1 = new ScooterBuilder();
    VehicleBuilder b2 = new CarBuilder();
    VehicleBuilder b3 = new MotorCycleBuilder();

    // Construct and display vehicles
    shop.Construct( b1 );
    b1.Vehicle.Show();

    shop.Construct( b2 );
    b2.Vehicle.Show();

    shop.Construct( b3 );
    b3.Vehicle.Show();
  }