コード例 #1
0
        public RatingResult Compute(IList<RestaurantReview> reviews)
        {
            var result = new RatingResult();
            var counter = 0;
            var total = 0;

            for (int i = 0; i < reviews.Count(); i++)
            {
                if (i < reviews.Count() / 2)
                {
                    counter += 2;
                    total += reviews[i].Rating * 2;
                }
                else
                {
                    counter += 1;
                    total += reviews[i].Rating;
                }
            }

            result.Rating = total / counter;
            return result;
        }
コード例 #2
0
 public RatingResult Compute(IList<RestaurantReview> reviews)
 {
     var result = new RatingResult();
     result.Rating = (int)reviews.Average(r => r.Rating);
     return result;
 }