/// <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"); } }