public int FindsProduct(Bookkeeping bookkeeping, string name) { int sum = 0; for (int i = 0; i < bookkeeping.waybill.Count; i++) { for (int j = 0; j < bookkeeping.waybill[i].products.Count; j++) { if (bookkeeping.waybill[i].products[j].name.Contains(name)) { sum += bookkeeping.waybill[i].products[j].cost; } } } return(sum); }
static void Main(string[] args) { Days days; days = Days.Monday; for (int i = 0; i < 6; i++) { Console.WriteLine(days); days++; } Person ann; ann.name = "Ann"; ann.age = 19; ann.DisplayInfo(); Product apple = new Product("apple", 30); Product pen = new Product("pen", 10); Product cat = new Product("cat", 1000); Waybill waybill1 = new Waybill(); Waybill waybill2 = new Waybill(); Check check1 = new Check(1999, 123); Check check2 = new Check(2003, 321); Bookkeeping bookkeeping = new Bookkeeping(); bookkeeping.Add(waybill1, check1); bookkeeping.Add(waybill2, check2); waybill1.products.Add(apple); waybill1.products.Add(apple); waybill1.products.Add(pen); waybill2.products.Add(pen); waybill2.products.Add(cat); bookkeeping.Output(); Controller controller = new Controller(); Console.WriteLine("\nCost of a product: " + controller.FindsProduct(bookkeeping, "cat")); Console.WriteLine("Quantity of checks: " + controller.CheckNumber(bookkeeping)); controller.FindDate(bookkeeping); bookkeeping.Remove(1); bookkeeping.Output(); }
public int CheckNumber(Bookkeeping bookkeeping) { return(bookkeeping.checks.Count); }