public override string ToString() { return(Foods.Select(x => x.HappinessPoints).Sum() + "\n" + Mood); }
public void CreateMealPlan() { List <string>[] ThePlan = new List <string> [3]; if (Foods != null) { //Macros double[] total = new double[3]; var foods = (Foods.Select(foo => foo)).ToList(); //seperating foods by time of day var breakfast = foods.Select(foo => foo.Breakfast = true).ToList(); var lunch = foods.Select(foo => foo.Lunch = true).ToList(); var dinner = foods.Select(foo => foo.Dinner = true).ToList(); var snack = foods.Select(foo => foo.Snack = true).ToList(); //number of items in each list int[] max = { breakfast.Count(), lunch.Count(), dinner.Count(), snack.Count() }; //randomizer Random rand = new Random(); /*************End of Variables*************/ ratioCheck(); for (int i = 0; i < 3; i++) { total[i] = (((double)TotalCalories / (macroRatio[i] / 100)) / 4) - 100; } total[3] = (double)TotalCalories - total[0] + total[1] + total[2]; //Generate Breakfast portion of plan for (int macros = 0; macros < 3; macros++) { for (int i = 0; i < total[macros];) { Food random = new Food(); random = (Food)breakfast.ElementAt(rand.Next(max[0])); i += random.Calories; ThePlan[0].Add(random.Name); } } //Generate Lunch portion of plan for (int macros = 0; macros < 3; macros++) { for (int i = 0; i < total[macros];) { Food random = new Food(); random = (Food)lunch.ElementAt(rand.Next(max[1])); i += random.Calories; ThePlan[1].Add(random.Name); } } //Generate dinner portion of plan for (int macros = 0; macros < 3; macros++) { for (int i = 0; i < total[macros];) { Food random = new Food(); random = (Food)dinner.ElementAt(rand.Next(max[2])); i += random.Calories; ThePlan[2].Add(random.Name); } } //Generate snack portion of plan for (int macros = 0; macros < 3; macros++) { for (int i = 0; i < total[macros];) { Food random = new Food(); random = (Food)snack.ElementAt(rand.Next(max[3])); i += random.Calories; ThePlan[3].Add(random.Name); } } } myPlan = ThePlan; }
public override string ToString() { return(string.Join(Environment.NewLine, Foods.Select(food => food.ToString()))); }
public Food GetFood(string name) { return(Foods.Select(food => food).Where(food => food.name.Contains(name)).Take(1).ToList().ElementAt(0)); }