public double CalculatePrice(double weight, Prices prices) { double price = 0; if (Diet != Diet.Omnivore) { var foodPrice = Diet == Diet.Herbivore ? prices.Fruits : prices.Meat; price = foodPrice * weight * Ratio; } else { var meatRatio = Ratio * MeatPercent; var fruitRatio = Ratio - meatRatio; price = prices.Fruits * weight * fruitRatio + prices.Meat * weight * meatRatio; } return(Math.Round(price, 3)); }
private static double CalculateCost(IEnumerable <Animal> animals, AnimalType type, Prices prices) { return(animals.Where(animal => animal.IsType(type)) .Aggregate(0.0, ((cost, animal) => cost + animal.CalculatePrice(prices)))); }
public double CalculatePrice(Prices prices) { return(_animalType.CalculatePrice(Weight, prices)); }