コード例 #1
0
        public static void Main()
        {
            var constructor = new VehicleConstructor();

            var carBuilder = new CarBuilder();
            constructor.Constructor(carBuilder);
            carBuilder.Vehicle.Show();

            var scooterBuilder = new ScooterBuilder();
            constructor.Constructor(scooterBuilder);
            scooterBuilder.Vehicle.Show();
        }
コード例 #2
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();
        }