コード例 #1
0
        public decimal GetCost(IEnumerable <IHarryPotterBook> books)
        {
            decimal cost = 0;

            int paymentSetCount = 0;

            while (books.Any(x => x.count > paymentSetCount))
            {
                IEnumerable <IHarryPotterBook> bookSets = books.Where(x => x.count > paymentSetCount);
                int      bookCount = bookSets.Count();
                IPayment payment   = GetPayment(bookCount);
                int      setCount  = bookSets.Min(x => x.count) - paymentSetCount;
                cost            += payment.GetCost(bookSets, setCount);
                paymentSetCount += setCount;
            }
            return(cost);
        }