Пример #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();
            }
        }
        /// <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");
            }
        }
Пример #3
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");
            }
        }
Пример #4
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();
        }
Пример #5
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();
        }