Esempio n. 1
0
        public override string ToString()
        {
            var header   = "List of items in basket:\n";
            var itemsMsg = Items.Aggregate(header,
                                           (x, y) => $"{x}{y.Product.Name}: {y.Num}, price: {y.GetPrice()} ({y.Product.Price} per unit)\n");
            var msg   = Discounts.Aggregate("", (x, y) => $"{x}{y.GetDescription()}\n");
            var total = $"Total amount: {Total}\n";

            return(Discounts.Any() ? $"{itemsMsg}\n{msg}\n{total}" : total);
        }