Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            var superCarBuilder           = new SuperCarBuilder();
            var notSoSuperCarBuilderButOk = new NotSoSuperCarBuilderButOk();

            var factory  = new CarFactory();
            var builders = new List <CarBuilder>
            {
                superCarBuilder,
                notSoSuperCarBuilderButOk
            };

            foreach (var builder in builders)
            {
                var car = factory.Build(builder);

                Console.WriteLine($"Samochód zamówiony przez " +
                                  $"'{builder.GetType().Name}': " +
                                  $"\n ------------------------------------" +
                                  $"\n Konie mechaniczne: {car.HorsePower}" +
                                  $"\n Najbardziej ceniony za: {car.MostImpressiveFeature}" +
                                  $"\n Maksymalna prędkość: {car.TopSpeed} km/s \n");

                Console.ReadKey();
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            var superCarBuilder = new SuperCarBuilder();
            var superCar        = new CarFactory().Build(superCarBuilder);

            var lameCarBuilder = new LameCarBuilder();
            var lameCar        = new CarFactory().Build(lameCarBuilder);

            // (could choose to put builders in a collection and iterate over each, calling .Build() on each)
        }
        /// <summary>
        /// The Client
        /// </summary>
        static void Main(string[] args)
        {
            var superBuilder      = new SuperCarBuilder();
            var notSoSuperBuilder = new NotSoSuperCarBuilder();

            var factory  = new CarFactory();
            var builders = new List <CarBuilder> {
                superBuilder, notSoSuperBuilder
            };

            foreach (var b in builders)
            {
                var car = factory.Build(b);
                Console.WriteLine($"The car requested by is {b.GetType().Name}:\n--------------------------------------------- " +
                                  $"\nHP: {car.HP}\nIpmressive Feature: {car.MostImpressiveFeature}" +
                                  $"\nTopSpeed: {car.TopSpeedMPH} mph\n");
            }
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            var classicCarBuilder = new ClassicCarBuilder();
            var racingCarBuilder  = new RacingCarBuilder();
            var builders          = new List <CarBuilder> {
                classicCarBuilder, racingCarBuilder
            };

            foreach (var carBuilder in builders)
            {
                var director = new CarFactory(carBuilder);
                director.BuildCar();
                var car = director.GetCar();
                car.DisplayCarInfo();
            }

            Console.ReadKey();
        }
Ejemplo n.º 5
0
        public static void Main()
        {
            var superBuilder    = new SuperCarBuilder();
            var notSuperBuilder = new NotSoSuperCarBuilder();

            var factory  = new CarFactory();
            var builders = new List <CarBuilder> {
                superBuilder, notSuperBuilder
            };

            foreach (var b in builders)
            {
                var c = factory.Build(b);
                Console.WriteLine($"The Car requested by " +
                                  $"{b.GetType().Name}: " +
                                  $"\n--------------------------------------" +
                                  $"\nHorse Power: {c.HorsePower}" +
                                  $"\nImpressive Feature: {c.MostImpressiveFeature}" +
                                  $"\nTop Speed: {c.TopSpeedMPH} mph\n");
            }
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            var superCarBuilder      = new SuperCarBuilder();
            var notSoSuperCarBuilder = new NotSoSuperCarBuilder();

            var carFactory  = new CarFactory();
            var carBuilders = new List <CarBuilder> {
                superCarBuilder, notSoSuperCarBuilder
            };

            foreach (var builder in carBuilders)
            {
                var car = carFactory.build(builder);

                Console.WriteLine("The Car requested by " +
                                  $"{builder.GetType().Name}: " +
                                  $"\n--------------------------------------------------" +
                                  $"\nHorse Power: {car.HorsePower} " +
                                  $"\nImpressive feature: {car.MostImpressiveCarFeature} " +
                                  $"\nTop Speed: {car.TopSpeedMPH} mph\n");
            }
        }
Ejemplo n.º 7
0
        // The Client
        static void Main(string[] args)
        {
            var superBuilder  = new SuperCar();
            var normalBuilder = new NormalCar();

            var factory = new CarFactory();
            var builder = new List <CarBuilder>
            {
                superBuilder, normalBuilder
            };

            foreach (var b in builder)
            {
                var c = factory.Build(b);
                Console.WriteLine($"The Car requested by " +
                                  $"{b.GetType().Name}" +
                                  $"\n-----------------------------" +
                                  $"\nHorse Power: {c.HorsePower}" +
                                  $"\nImpressive Feature: {c.MostImpressiveFeature}" +
                                  $"\nTop Speed: {c.TopSpeedMPH}\n");
            }

            Console.ReadKey();
        }
Ejemplo n.º 8
0
        public static void CreateCarsManually()
        {
            var carFactory = new CarFactory();
            var builders   = new List <CarBuilder> {
                new SmallCarBuilder(),
                new BigCarBuilder()
            };

            foreach (var builder in builders)
            {
                var car = carFactory.Build(builder);

                Console.WriteLine($"\nThe car created by " +
                                  $"{builder.GetType().Name}: " +
                                  $"\nSpeed: {car.MaxSpeed}" +
                                  $"\nPower: {car.MaxPower} " +
                                  $"\nColor: {car.Color}");

                car.Drive();
            }
            ;

            Console.ReadKey();
        }