public static IComputerManufacturer GetManufacturer(string manufacturerName) { IComputerManufacturer manufacturer; switch (manufacturerName) { case GlobalConstants.HpName: { manufacturer = new HpManufacturer(); break; } case GlobalConstants.DellName: { manufacturer = new DellManufacturer(); break; } default: { throw new InvalidArgumentException("Invalid manufacturer name"); } } return(manufacturer); }
public Manufacturer Create(string manufacturer) { Manufacturer computerFactory; if (manufacturer == HP) { computerFactory = new HpManufacturer(); } else if (manufacturer == Dell) { computerFactory = new DellManufacturer(); } else if (manufacturer == Lenovo) { computerFactory = new LenovoManufacturer(); } else { throw new ArgumentException(InvalidManufacturerMessage); } return(computerFactory); }