Exemple #1
0
        public decimal CalculateBasketTotal()
        {
            var basketTotal = 0m;

            var grouper = new BookGrouper();

            var distinctProductGroups = grouper.SortBooksIntoDistinctGroups(this.basket.Books);

            var productDiscounter = new PriceDiscountCalculator();

            foreach (var distinctProductGroup in distinctProductGroups)
            {
                var totalGroupPrice = GetGroupPrice(distinctProductGroup.Count, this.fullProductPrice);

                basketTotal += productDiscounter.TotalDiscountAppliedToDistinctBookCollection(
                    distinctProductGroup.Count,
                    totalGroupPrice);
            }

            return(basketTotal);
        }
        private decimal GetDicountedPrice(int numberOfBooks, decimal bookCollectionPrice)
        {
            var discountCalculator = new PriceDiscountCalculator();

            return(discountCalculator.TotalDiscountAppliedToDistinctBookCollection(numberOfBooks, bookCollectionPrice));
        }