Esempio n. 1
0
        //建造者模式的调用
        public static void GetBuilder()
        {
            Director director        = new Director();
            Builder  buickCarBuilder = new BuickBuilder();
            Builder  aoDiCarBuilder  = new AoDiBuilder();

            director.Construct(buickCarBuilder);
            //组装完成了,我来驾驶别克了
            Car1 buickCar = buickCarBuilder.GetCar();

            buickCar.Show();

            director.Construct(aoDiCarBuilder);
            Car1 aoDiCar = aoDiCarBuilder.GetCar();

            aoDiCar.Show();
        }
Esempio n. 2
0
            static void Main(string[] args)
            {
                Director director        = new Director();
                Builder  buickCarBuilder = new BuickBuilder();
                Builder  aoDiCarBuilder  = new AoDiBuilder();

                director.Construct(buickCarBuilder);

                //组装完成,我来驾驶别克了
                Car buickCar = buickCarBuilder.GetCar();

                buickCar.Show();

                // 我老婆就要奥迪了,她比较喜欢大品牌
                director.Construct(aoDiCarBuilder);
                Car aoDiCar = aoDiCarBuilder.GetCar();

                aoDiCar.Show();

                Console.Read();
            }