Esempio n. 1
0
        public void Ex1()
        {
            // Buildern skickas till "directorn"
            var director = new Director();
            var builder  = new ConcreteBuilder();

            director.Builder = builder;

            // Initiera konstruktionsprocessen
            Console.WriteLine("Standard basic product:");
            director.BuildMinimalViableProduct();

            // Slutresultatet kommer från byggobjektet
            Console.WriteLine(builder.GetProduct().ListParts());

            // Skapa något mer avancerat

            Console.WriteLine("Standard full featured product:");
            director.BuildFullFeaturedProduct();

            // Samma kod som innan för att generera resultat
            Console.WriteLine(builder.GetProduct().ListParts());

            // Det går att använda "builder pattern" utan "director"
            Console.WriteLine("Custom product:");
            builder.BuildPartA();
            builder.BuildPartC();
            Console.Write(builder.GetProduct().ListParts());
        }
Esempio n. 2
0
        private void btnMontar_Click(object sender, EventArgs e)
        {
            this.Size = new Size(448, 450);

            var    director = new Director();
            var    builder  = new ConcreteBuilder();
            string aux      = "";

            builder.BuildPartA();
            builder.BuildPartB();
            builder.BuildPartC();

            var     decide    = new EscreveStr();
            Product resultado = new Product();

            string str = decide.Texto(ckbA.Checked, ckbB.Checked, ckbC.Checked);

            picCarro.Image = imageList1.Images[resultado.EscolheImagem(str)];
        }