protected Product CreateProduct(string type, string name, int price, int size) { Product product; switch (type) { case "CD": product = new CDProduct(name, price, size); break; case "Book": product = new BookProduct(name, price, size); break; default: throw new Exception("There is no such type!"); } return(product); }
protected Product CreateProduct(string type, string name, int price, int size) { Product resultProduct; switch (type) { case "CD": resultProduct = new CDProduct(name, price, size); break; case "Book": resultProduct = new CDProduct(name, price, size); break; default: throw new Exception("Wrong type"); } return(resultProduct); }