public void addProduct() { Product p = new Product(); Console.WriteLine("Enter product name: "); p.name = Console.ReadLine(); Console.WriteLine("Enter product quantity: "); try { p.quantity = int.Parse(Console.ReadLine()); } catch (FormatException) { Console.WriteLine("Not a number idiot"); } Console.WriteLine("Enter product price: "); p.price = Console.ReadLine(); Console.WriteLine("Enter product category: "); p.category = Console.ReadLine(); inventory.Add(p); }
public Product searchForProduct() { Product p = new Product(); Console.WriteLine("Enter product name: "); p.name = Console.ReadLine(); for (int i = 0; i < inventory.Count; i++) { if (string.Equals(p.name, inventory[i].name)) { return inventory[i]; } } return null; }