static void Main() { // Econical car, blue VehicleFactory vCarFactory = new CarFactory(); IVehicle vCar = vCarFactory.Build (VehicleFactory.DrivingStyle.Economical, VehicleColour.Blue); WriteLine(vCar); // White van VehicleFactory vVanFactory = new VanFactory(); IVehicle vVan = vVanFactory.Build (VehicleFactory.DrivingStyle.Powerful, VehicleColour.White); WriteLine(vVan); // Red Sports car using static factory IVehicle vSportsVehicle = VehicleFactory.Make ( VehicleFactory.BuildWhat.Car , VehicleFactory.DrivingStyle.Powerful , VehicleColour.Red ); WriteLine(vSportsVehicle); ReadKey(); }
public Sample() { VehicleFactory carFactory = new CarFactory(); carFactory.Build(VehicleFactory.DrivingStyle.Economical, VehicleColour.Blue); VehicleFactory vanFactory = new VanFactory(); vanFactory.Build(VehicleFactory.DrivingStyle.Economical, VehicleColour.Silver); }
public void CarFactoryMethodTest() { //given VehicleFactory carFactory = new CarFactory(); //When IVehicle car = carFactory.Build(VehicleFactory.DrivingStyle.Economical, VehicleColour.Blue); //then Assert.AreEqual(car.GetType(), typeof(Saloon)); }
/// <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--------------------------------------" + $"\nHorse Power: {c.HorsePower}" + $"\nImpressive Feature: {c.MostImpressiveFeature}" + $"\nTop Speed: {c.TopSpeedMPH} mph\n"); } }
public void BuildMicroCar(Location location) { _carFactory.Build(CarType.MICRO, location); }
public static void Main() { // I want an economical car, coloured blue VehicleFactory carFactory = new CarFactory(); IVehicle car = carFactory.Build( VehicleFactory.DrivingStyle.Economical, VehicleColour.Blue); Console.WriteLine(car); // I want a "white van" VehicleFactory vanFactory = new VanFactory(); IVehicle van = vanFactory.Build( VehicleFactory.DrivingStyle.Powerful, VehicleColour.White); Console.WriteLine(van); // use the static Make method to create a red sports car IVehicle sporty = VehicleFactory.Make( VehicleFactory.Category.Car, VehicleFactory.DrivingStyle.Powerful, VehicleColour.Red); Console.WriteLine(sporty); }