コード例 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Builder");
            Console.WriteLine("House Construction Example");

            var houseDirector = new HouseDirector();

            var stoneHouseBuilder = new StoneHouseBuilder();

            houseDirector.SetBuilder(stoneHouseBuilder);

            Console.WriteLine("\n[Simple Stone House]");
            houseDirector.BuildSimpleHouse();
            var simpleStoneHouse = stoneHouseBuilder.Build();

            PrintResult(simpleStoneHouse);

            Console.WriteLine("\n[Nice Stone House]");
            houseDirector.BuildNiceHouse();
            var niceStoneHouse = stoneHouseBuilder.Build();

            PrintResult(niceStoneHouse);

            Console.WriteLine("\n[Simple Wood House]");
            var woodHouseBuilder = new WoodHouseBuilder();

            houseDirector.SetBuilder(woodHouseBuilder);

            houseDirector.BuildSimpleHouse();
            var simpleWoodHouse = woodHouseBuilder.Build();

            PrintResult(simpleWoodHouse);

            Console.WriteLine("\n[Nice Wood House]");
            houseDirector.BuildNiceHouse();
            var niceWoodHouse = woodHouseBuilder.Build();

            PrintResult(niceWoodHouse);
        }
コード例 #2
0
ファイル: Builder_Run.cs プロジェクト: SijyKijy/Patterns
        public override void Run()
        {
            // Стройка через директора
            var builder  = new ModernHouseBuilder(new ModernHouse());
            var director = new Director(builder);

            director.BuildModernHouse();
            director.BuildSimpleHouse();

            // Стройка руками
            System.Console.WriteLine("Строим ручками");
            var builder2 = new WoodHouseBuilder(new WoodHouse());

            builder2.BuildFloor();
            builder2.BuildWoodTable();
            System.Console.WriteLine(builder2.Build().GetParts());
        }