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 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 GetManufacturer(string name) { Manufacturer manufacturer; if (name == "HP") { manufacturer = new HPManufacturer(); } else if (name == "Dell") { manufacturer = new DellManufacturer(); } else if (name == "Lenovo") { manufacturer = new LenovoManufacturer(); } else { throw new InvalidArgumentException("Invalid manufacturer!"); } 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); }