Example #1
0
        public float CalculatePurchasePrice()
        {
            var count = GetAppleCount();

            Fruit[] fruits     = new Apple[count];
            var     totalPrice = fruits.Sum(fruit => fruit.Price);

            count       = GetPearCount();
            fruits      = new Pear[count];
            totalPrice += fruits.Sum(fruit => fruit.Price);

            count       = GetPlumCount();
            fruits      = new Plum[count];
            totalPrice += fruits.Sum(fruit => fruit.Price);

            return(totalPrice);
        }
Example #2
0
        public float CalculatePurchasePrice()
        {
            var appleCount = GetAppleCount();
            var apples     = new Apple[appleCount];
            var totalPrice = apples.Sum(fruit => fruit.Price);

            var pearCount = GetPearCount();
            var pears     = new Pear[pearCount];

            totalPrice += pears.Sum(fruit => fruit.Price);

            var plumCount = GetPlumCount();
            var plums     = new Plum[plumCount];

            totalPrice += plums.Sum(fruit => fruit.Price);

            return(totalPrice);
        }