/// <summary> /// Runners this instance. /// </summary> public void Runner() { ////creating object of concrete using the reference of an interface VehicleFactory factory = new ConcreteVehicleFactory(); ////calling method using the reference of an interface IFactory scooter = factory.GetVehicle("Scooter"); scooter.Drive(10); ////calling method using reference of an interface IFactory bike = factory.GetVehicle("Bike"); bike.Drive(20); }
static void Main(string[] args) { VehicleFactory factory = new ConcreteVehicleFactory(); IVehicle scooter = factory.GetVehicle("Scooter"); scooter.Drive(10); IVehicle bike = factory.GetVehicle("Bike"); bike.Drive(20); Console.ReadKey(); }
private static void FactoryPattern() { VehicleFactory factory = new ConcreteVehicleFactory(); IFactory scooter = factory.GetVehicle("Scooter"); scooter.Drive(10); IFactory bike = factory.GetVehicle("Bike"); bike.Drive(20); Console.ReadKey(); }