Exemple #1
0
 protected CarFactoryBase(CarBuilderBase builder)
 {
     CarBuilder = builder;
 }
Exemple #2
0
 public LuxuryCar(CarBuilderBase builder) : base(builder)
 {
 }
Exemple #3
0
 public CheapCarFactory(CarBuilderBase builder) : base(builder)
 {
 }
        public Car CreateCarSelectedConfiguration(string selectedNumberModel)
        {
            if (IsModelValid(selectedNumberModel))
            {
                switch (selectedNumberModel)
                {
                    case "1":
                        carBuilder = new LandCruiserBuilder();
                        try
                        {
                            carBuilder.BuildCarWithFullCOnfigurations();

                            this.builtCar = carBuilder.GetCar();

                            Console.WriteLine(this.builtCar.ToString());
                        }
                        catch(NullReferenceException)
                        {
                            Console.WriteLine("Incorrect data: NullReferebceException");
                        }

                        break;

                    case "2":
                        carBuilder = new CamryBuilder();
                        
                        try
                        {
                            carBuilder.BuildCarWithFullCOnfigurations();

                            this.builtCar = carBuilder.GetCar();

                            Console.WriteLine(this.builtCar.ToString());
                        }
                        catch (NullReferenceException)
                        {
                            Console.WriteLine("Incorrect data: NullReferebceException");
                        }

                        break;

                    case "3":
                        carBuilder = new CorollaBuilder();
                        try
                        {
                            carBuilder.BuildCarWithFullCOnfigurations();

                            builtCar = carBuilder.GetCar();

                            Console.WriteLine(builtCar.ToString());
                        }
                        catch (NullReferenceException)
                        {
                            Console.WriteLine("Incorrect data: NullReferebceException");
                        }

                        break;
                }
            }
            return builtCar;
        }
 public RegularCar(CarBuilderBase builder) : base(builder)
 {
 }
 public LuxuryCarFactory(CarBuilderBase builder) : base(builder)
 {
 }