Esempio n. 1
0
        /// <summary>
        /// The Client
        /// </summary>
        static void Main(string[] args)
        {
            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-----------------------------------" +
                                  $"\nDoors: {c.Doors}" +
                                  $"\nSeats: {c.Seats}" +
                                  $"\nHorse power: {c.HorsePower}" +
                                  $"\nImpressive feature: {c.MostImpressiveFeature}" +
                                  $"\nTop speed: {c.TopSpeedMPH} mph\n");
            }
        }
        /// <summary>
        /// The Client
        /// </summary>
        static void Main(string[] args)
        {
            //all other classes were written by the prof ahead of time

            //instantiate a couple builders:
            var superBuilder      = new SuperCarBuilder();
            var notSoSuperBuilder = new NotSoSuperCarBuilder();

            //instantiate a car factory:
            var factory = new Carfactory();

            //create a collection of the car builders:
            //(so we can later loop through them)
            var builders = new List <CarBuilder> {
                superBuilder, notSoSuperBuilder
            };

            //for each builder
            //first assign "car" within this loop
            //to one builder at a time.
            //then get the specs for that car.
            foreach (var builder in builders)
            {
                var car = factory.Build(builder);
                Console.WriteLine($"The car requested by " +
                                  $"{builder.GetType().Name}: " +
                                  $"\nHorsepower: {car.HorsePower}" +
                                  $"\nImpressive feature: {car.MostImpressiveFeature}" +
                                  $"\nTop Speed: {car.TopSpeedMPH} mph.\n");
            }
        }
        /// <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");
            }
        }
        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");
            }
        }