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); }
public static ICollection <IVegetable> GetSortIngredByProtein(this Salad salad) => salad.GetIngredients().OrderBy(item => item.Protein).ToList <IVegetable>();
public static ICollection <IVegetable> GetSortIngredByCarbohydrates(this Salad salad) => salad.GetIngredients().OrderBy(item => item.Carbohydrates).ToList <IVegetable>();