public VanRange() { vans = new IVehicle[3]; // Define the range of van models available vans[0] = new BoxVan(new StandardEngine(1600)); vans[1] = new BoxVan(new StandardEngine(2000)); vans[2] = new Pickup(new TurboEngine(2200)); }
static void Main() { IEngine e1 = new StandardEngine(1300); IEngine e2 = new TurboEngine(1600); IVehicle v1 = new Saloon(e1); IVehicle v2 = new Coupe(e1, VehicleColour.Blue); IVehicle v3 = new BoxVan(e2, VehicleColour.White); Console.WriteLine(v1); Console.WriteLine(v2); Console.WriteLine(v3); Console.Read(); }
static void Main() { IEngine e1 = new StandardEngine(1300); IEngine e2 = new TurboEngine(1600); IVehicle v1 = new Saloon(e1); IVehicle v2 = new Coupe(e1, VehicleColour.Blue); IVehicle v3 = new BoxVan(e2, VehicleColour.White); Console.WriteLine(v1); Console.WriteLine(v2); Console.WriteLine(v3); Console.Read(); }
protected internal override IVehicle SelectVehicle(DrivingStyle style) { IVehicle selectedVehicle; if ((style == DrivingStyle.Economical) || (style == DrivingStyle.Midrange)) { selectedVehicle = new Pickup(new StandardEngine(2200)); } else { selectedVehicle = new BoxVan(new TurboEngine(2500)); } return selectedVehicle; }