public Menu() { Desert cake = new Desert(12.3); Drink tea = new Drink(2.5); Salad greeceSalad = new Salad(22.0); Entree beef = new Entree(122.8); this.currentMenu.Add(cake); this.currentMenu.Add(tea); this.currentMenu.Add(greeceSalad); this.currentMenu.Add(beef); }
static void Main(string[] args) { string[] input = Console.ReadLine().Split(new string[] { ", " }, StringSplitOptions.None).ToArray(); List <Product> menuProducts = new List <Product>(); Dictionary <int, List <Product> > orders = new Dictionary <int, List <Product> >(); while (!int.TryParse(input[0], out int random)) { string type = input[0]; string name = input[1]; int weight = int.Parse(input[2]); decimal price = decimal.Parse(input[3]); if (type == "MainDish") { MainDish mainDish = new MainDish(); mainDish.Type = type; mainDish.Name = name; mainDish.Weight = weight; mainDish.Price = price; menuProducts.Add(mainDish); } else if (type == "Drink") { Drink drink = new Drink(); drink.Type = type; drink.Name = name; drink.Weight = weight; drink.Price = price; menuProducts.Add(drink); } else if (type == "Desert") { Desert desert = new Desert(); desert.Type = type; desert.Name = name; desert.Weight = weight; desert.Price = price; menuProducts.Add(desert); } else if (type == "Salad" || type == "Soup") { Product product = new Product(); product.Type = type; product.Name = name; product.Weight = weight; product.Price = price; menuProducts.Add(product); } else { Console.WriteLine("invalid article"); } input = Console.ReadLine().Split(new string[] { ", " }, StringSplitOptions.None).ToArray(); } while (input[0] != "Exit") { if (input[0] == "Sales") { Console.WriteLine($"Tables total count: {orders.Count}"); TotalSales(orders); Console.WriteLine("By categories: "); PrintSalad(orders); PrintSoup(orders); PrintMainDish(orders); PrintDesert(orders); PrintDrink(orders); input = Console.ReadLine().Split(new string[] { ", " }, StringSplitOptions.None).ToArray(); continue; } int table = int.Parse(input[0]); MakeOrder(table, orders, input, menuProducts); input = Console.ReadLine().Split(new string[] { ", " }, StringSplitOptions.None).ToArray(); } Console.WriteLine($"Tables total count: {orders.Count}"); TotalSales(orders); Console.WriteLine("By categories: "); PrintSalad(orders); PrintSoup(orders); PrintMainDish(orders); PrintDesert(orders); PrintDrink(orders); }