public static void Main() { FactoryEnum selectedFactory = (FactoryEnum)Enum.Parse(typeof(FactoryEnum), Console.ReadLine()); IVehicleFactory factory = GetFactory(selectedFactory); ICar car = factory.GetCar(); Console.WriteLine(car.Type()); ITruck truck = factory.GetTruck(); Console.WriteLine(truck.Type()); }
public static void Main_xx(string[] args) { IVehicleFactory hondaFactory = Client.GetFactory("Honda"); var city = hondaFactory.GetCar("City"); Console.WriteLine(city.GetType().Name); var truck = hondaFactory.GetTruck("Valcano"); Console.WriteLine(truck.GetType().Name); IVehicleFactory toyotaFactory = Client.GetFactory("Toyota"); var gli = toyotaFactory.GetCar("Gli"); Console.WriteLine(gli.GetType().Name); truck = toyotaFactory.GetTruck("TruckB"); Console.WriteLine(truck.GetType().Name); Console.ReadKey(); }