예제 #1
0
        public static ICollection <IVegetable> GetVegetablesInCaloriesRange(this Salad salad, int fromRange, int toRange)
        {
            ICollection <IVegetable> result = new List <IVegetable>();

            foreach (var vegetable in salad.GetIngredients())
            {
                if ((vegetable.Calories >= fromRange) && (vegetable.Calories <= toRange))
                {
                    result.Add(vegetable);
                }
            }
            return(result);
        }
예제 #2
0
 public static ICollection <IVegetable> GetSortIngredByProtein(this Salad salad) => salad.GetIngredients().OrderBy(item => item.Protein).ToList <IVegetable>();
예제 #3
0
 public static ICollection <IVegetable> GetSortIngredByCarbohydrates(this Salad salad) => salad.GetIngredients().OrderBy(item => item.Carbohydrates).ToList <IVegetable>();