Exemplo n.º 1
0
        public static void ViewStorage(List <IItem> Storage, int days)
        {
            Console.WriteLine(days > 0 ? $"Items table after {days} days:" : "Items table:");

            ConsoleTable table = new ConsoleTable(
                new List <string> {
                "ID", "Name", "Type", "Amount", "Price", "Expiration Days"
            },
                new List <int> {
                2, 12, 12, 6, 5, 20
            }
                );

            foreach (IItem item in Storage)
            {
                if (item.IsExpired(days))
                {
                    table.Add(new string[] {
                        (Storage.IndexOf(item) + 1).ToString(),
                        item.ItemName,
                        item.Type,
                        item.Amount.ToString(),
                        item.Price.ToString(),
                        item.ExpirationDays.ToString()
                    });
                }
            }

            Console.WriteLine(table.ToString());
        }