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); }