示例#1
0
        static void Main(string[] args)
        {
            Director         director = new Director();
            CarManualBuilder builder  = new CarManualBuilder();

            director.MakeSportsCars(builder);
            Manual manual = builder.getResults();

            foreach (var item in manual.ListaPasos)
            {
                Console.WriteLine(item);
            }
            Console.ReadLine();
        }
示例#2
0
        public static void Main()
        {
            Director director = new Director();

            // EN: Director gets the concrete builder object from the client
            // (application code). That's because application knows better which
            // builder to use to get a specific product.
            //
            // RU: Директор получает объект конкретного строителя от клиента
            // (приложения). Приложение само знает какой строитель использовать,
            // чтобы получить нужный продукт.
            CarBuilder builder = new CarBuilder();

            director.ConstructSportsCar(builder);

            // EN: The final product is often retrieved from a builder object,
            // since Director is not aware and not dependent on concrete
            // builders and products.
            //
            // RU: Готовый продукт возвращает строитель, так как Директор чаще
            // всего не знает и не зависит от конкретных классов строителей
            // и продуктов.
            Car car = builder.GetResult();

            Console.WriteLine("Car built:\n" + car.GetType());

            CarManualBuilder manualBuilder = new CarManualBuilder();

            // EN: Director may know several building recipes.
            //
            // RU: Директор может знать больше одного рецепта строительства.
            director.ConstructSuv(manualBuilder);
            Manual carManual = manualBuilder.getResult();

            Console.WriteLine("\nCar manual built:\n" + carManual.Print());

            Console.ReadKey();
        }
示例#3
0
        public static void Main(string[] args)
        {
            // The client code creates a builder object, passes it to the
            // director and then initiates the construction process. The end
            // result is retrieved from the builder object.
            var director = new Director();
            var builder  = new Car();//In this case, the builder it's the type of object. Example car object or car manual object

            director.Builder = builder;

            var director2 = new Director();
            var manual    = new Manual();

            director2.Builder = manual;


            Console.WriteLine("Standard basic product:");
            director.SimpleCar();
            Console.WriteLine(builder.GetCar().ListParts());
            Console.WriteLine("Manual product:");
            director2.SimpleCarManual();
            Console.WriteLine(manual.GetManual().ListParts());

            Console.WriteLine("Standard full featured product:");
            director.MakeSportCar();
            Console.WriteLine(builder.GetCar().ListParts());

            // Remember, the Builder pattern can be used without a Director
            // class.
            Console.WriteLine("Custom product:");
            builder.ResetCar();
            builder.SetEngine();
            Console.Write(builder.GetCar().ListParts());

            Console.ReadLine();
        }
示例#4
0
 public CarManualBuilder()
 {
     manualAuto = new Manual();
 }
 public void reset()
 {
     manualCar = new Manual();
 }
示例#6
0
        /// <summary>
        /// The reset method clears the object being built.
        /// </summary>
        public IBuilder Reset()
        {
            manual = new Manual();

            return(this);
        }