public static void deleteComboRows(IMeal meal) { string type = "BonDrucker.MealCombination"; writeFileNameToProperty(type); var mealList = readCombos(type); // Suche Index des zu aktualisierenden Element ueber die GUID if (meal.GetType().ToString().Contains("MainMeal")) { mealList.RemoveAll(x => x.mainMealGUID == meal.guid); } else { mealList.RemoveAll(x => x.secondMealGUID == meal.guid); } if (mealList.Count == 0) { deleteAll(type); } else { write(mealList); } }
public ProductModel(IMeal service, ICart newCartService, IUserService uService) { mealService = service; cartService = newCartService; UserService = uService; CartInput = new CartItem(); }
public Order(IMeal meal, IBeverage beverage, IDessert dessert, bool withCoffee) { Meal = meal; Beverage = beverage; Dessert = dessert; WithCoffee = withCoffee; }
public void Add(IMeal knapsack) { if (Count < (SortedMeals.Count + Children.Count)) { return; } Children.Add(knapsack); }
public Meal BuildMeal(IMeal builder) { builder.BuildMeal(); builder.BuildDrink(); builder.BuildMain(); builder.BuildSide(); builder.BuildToy(); return(builder.getMeal()); }
public static void addToCSV(IMeal meal) { string type = meal.GetType().ToString(); writeFileNameToProperty(type); var mealList = readMeals(type); mealList.Add(meal); write(mealList); }
public override void Execute() { Console.WriteLine("Please enter desired meal name (green salad/hamburger): "); string mealName = Console.ReadLine(); MealFactory factory = new MealFactory(); IMeal meal = factory.CreateMeal(mealName); meal.ShowDescription(); meal.ShowAmountOfCalories(); }
private void uiBtnAddMeal_Click(object sender, EventArgs e) { IMeal selectedMeal = uiLstMeals.SelectedItem as IMeal; if (selectedMeal == null) { return; } _logic.AddMeal(new Entity.Meal(selectedMeal.MealName, selectedMeal.MealPrice, selectedMeal.MealGroup)); ReloadTree(); }
public static void updateCSV(IMeal meal) { string type = meal.GetType().ToString(); writeFileNameToProperty(type); var mealList = readMeals(type); // Suche Index des zu aktualisierenden Element ueber die GUID int index = mealList.FindIndex(x => x.guid == meal.guid); mealList[index] = meal; write(mealList); }
private IMeal[] Crossover(IMeal firstParent, IMeal secondParent, IEnumerable <DietaryReferenceIntake> maxWeight, IEnumerable <Food> foods) { int i = MyRandom.Next(Math.Min(firstParent.FoodIntakesCount, secondParent.FoodIntakesCount)); var firstParentPart1 = firstParent.Take(i); var secondParentPart2 = secondParent.Skip(i); var firstParentPart2 = firstParent.Skip(i); var secondParentPart1 = secondParent.Take(i); var child1 = FillChildKnapsack(maxWeight, firstParentPart1, secondParentPart1, foods); var child2 = FillChildKnapsack(maxWeight, secondParentPart2, firstParentPart2, foods); return(child1.CompareTo(child2) >= 0 ? new IMeal[] { child1, child2 } : new IMeal[] { child2, child1 }); }
private static TreeNode AddSubOrderedItems(IMeal pMeal) { var mealNode = new TreeNode($"{pMeal.MealName} ({pMeal.MealPrice} zł)"); if (pMeal.AddOns == null || !pMeal.AddOns.Any()) { return(mealNode); } foreach (var mealAddOn in pMeal.AddOns) { mealNode.Nodes.Add(AddSubOrderedItems(mealAddOn)); } return(mealNode); }
private void checkBox_Insertable(object sender, RoutedEventArgs e) { try { if (sender != null) { var result = sender as CheckBox; IMeal meal = result.DataContext as IMeal; meal.insertable = result.IsChecked.HasValue ? result.IsChecked.Value : false; changeMeal(meal); } } catch (Exception) { } }
public static ORDER_ITEMS ConvertMealToOrderItemDb(IMeal pMeal) { var orderItem = new ORDER_ITEMS { NAME = pMeal.MealName, PRICE = (double)pMeal.MealPrice }; if (pMeal.AddOns != null && pMeal.AddOns.Any()) { foreach (var mealAddOn in pMeal.AddOns) { orderItem.ORDER_ITEMS1.Add(ConvertMealToOrderItemDb(mealAddOn)); } } return(orderItem); }
private void Mutate(IMeal knapsack, Population population) { if (knapsack.FoodIntakesCount > 0) { if (MyRandom.Next(0, 1) < 0.5) { var removeIndex = MyRandom.Next(knapsack.FoodIntakesCount); knapsack.Remove(removeIndex); } else { var intakeToChange = knapsack.FoodIntakes.GetRandomMember(); knapsack.ChangeIntake(intakeToChange, MyRandom.Next(0.1, 4)); } } knapsack.Fill(population.Foods); }
public static void deleteRow(IMeal meal) { string type = meal.GetType().ToString(); writeFileNameToProperty(type); var mealList = readMeals(type); // Suche Index des zu loeschenden Element ueber die GUID int index = mealList.FindIndex(x => x.guid == meal.guid); mealList.RemoveAt(index); if (mealList.Count == 0) { deleteAll(type); } else { write(mealList); } }
public virtual IMeal CreateMeal(IMyContext db, string period) { IMeal meal = null; switch (period) { case "manhã": case "manha": meal = new DayMeal(db); break; case "noite": meal = new NightMeal(db); break; default: throw new ArgumentException("Pedido inválido"); } return(meal); }
public int CompareTo(IMeal other) { //bool bigger = DietaryReferenceIntakes.All(dri => TotalCost.GetNutrientValue(dri.NutrientName) > other.TotalCost.GetNutrientValue(dri.NutrientName)); //if (bigger) //{ // return -1; //} //bool smaller = DietaryReferenceIntakes.All(dri => TotalCost.GetNutrientValue(dri.NutrientName) < other.TotalCost.GetNutrientValue(dri.NutrientName)); //if (smaller) //{ // return 1; //} if (TotalCostSum == other.TotalCostSum) { return(base.Equals(other) ? 0 : GetHashCode().CompareTo(other.GetHashCode())); } return(TotalCostSum.CompareTo(other.TotalCostSum)); }
public void Cook() { if (mornToggle.isOn) { requirements.mealTime = 0; } else if (aftToggle.isOn) { requirements.mealTime = 1; } else { requirements.mealTime = 2; } requirements.competence = compToggle.isOn; requirements.IsHuman = humanToggle.isOn; questionsUI.gameObject.SetActive(false); MealFactory factory = new MealFactory(requirements); IMeal m = factory.Create(); foodName.gameObject.SetActive(true); if (m is Onion) { foodName.text = "It's all Ogre now." + "\n\n\n\n\n\n\n\nPress Enter to play again!"; } else { foodName.text = "Enjoy your " + m.ToString() + "!\n\n\n\n\n\n\nPress Enter to play again!"; } GameObject.Instantiate(Resources.Load(m + "Prefab")); }
private void addMainMealToDataGrid(IMeal meal) { mainMeals.Add(meal); mainMealList.Items.Refresh(); }
public void RemoveMeal(IMeal pMeal) { _meals.Remove(pMeal); }
public void AddMeal(IMeal pMeal) { _meals.Add(pMeal); }
private int getMeal(IMeal meal, IProduct protProduct, IProduct carbProduct, IProduct fatProduct) { float[,] macroElements = new float[3, 3]; macroElements[0, 0] = (float)protProduct.Protein; macroElements[0, 1] = (float)carbProduct.Protein; macroElements[0, 2] = (float)fatProduct.Protein; macroElements[1, 0] = (float)protProduct.Carbs; macroElements[1, 1] = (float)carbProduct.Carbs; macroElements[1, 2] = (float)fatProduct.Carbs; macroElements[2, 0] = (float)protProduct.Fat; macroElements[2, 1] = (float)carbProduct.Fat; macroElements[2, 2] = (float)fatProduct.Fat; D2Matrix constValues = new D2Matrix(macroElements); float[] macroElementsTotal = new float[] { (float)meal.TotalGramsOfProteins, (float)meal.TotalGramsOfCarbs, (float)meal.TotalGramsOfFats }; float matrixDet = constValues.GetDeterminantSquareMatrix(); macroElements = constValues.GetComplementMatrix(matrixDet); constValues = new D2Matrix(macroElements); constValues.InverseMatrix(matrixDet); constValues.MatrixTransposition(); float[] resultArray = new float[3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { resultArray[i] += constValues[i, j] * macroElementsTotal[j]; } } int errorCode = 0; if (resultArray[0] < 0 || resultArray[1] < 0 || resultArray[2] < 0) { if (protProduct.Rating <= carbProduct.Rating && protProduct.Rating <= fatProduct.Rating) { return(errorCode = 1); } else if (carbProduct.Rating <= protProduct.Rating && carbProduct.Rating <= fatProduct.Rating) { return(errorCode = 2); } else if (fatProduct.Rating <= protProduct.Rating && fatProduct.Rating <= carbProduct.Rating) { return(errorCode = 3); } } meal.MealProducts.Add(protProduct, (decimal)resultArray[0] * 100); meal.MealProducts.Add(carbProduct, (decimal)resultArray[1] * 100); meal.MealProducts.Add(fatProduct, (decimal)resultArray[2] * 100); return(errorCode); }
private void composeMeal(List <IProduct> productsForCurrentMeal, IMeal meal) { var currentMacroElement = productsForCurrentMeal[0].MacroElement; int weightOfComponent = 0; switch (currentMacroElement) { case MainSourceOf.Protein: { for (int i = 0; i < productsForCurrentMeal.Count; i++) { if (meal.TotalGramsOfProteins <= 0) { break; } weightOfComponent = (int)((meal.TotalGramsOfProteins * 100) / productsForCurrentMeal[i].Protein); meal.TotalGramsOfCarbs -= (weightOfComponent * productsForCurrentMeal[i].Carbs) / 100; meal.TotalGramsOfFats -= (weightOfComponent * productsForCurrentMeal[i].Fat) / 100; meal.MealProducts.Add(productsForCurrentMeal[i], weightOfComponent); ChoosenProducts.Remove(productsForCurrentMeal[i]); break; } break; } case MainSourceOf.Carbs: { for (int i = 0; i < productsForCurrentMeal.Count; i++) { if (meal.TotalGramsOfCarbs <= 0) { break; } weightOfComponent = (int)((meal.TotalGramsOfCarbs * 100) / productsForCurrentMeal[i].Carbs); meal.TotalGramsOfProteins -= (weightOfComponent * productsForCurrentMeal[i].Protein) / 100; meal.TotalGramsOfFats -= (weightOfComponent * productsForCurrentMeal[i].Fat) / 100; meal.MealProducts.Add(productsForCurrentMeal[i], weightOfComponent); ChoosenProducts.Remove(productsForCurrentMeal[i]); break; } break; } case MainSourceOf.Fat: { for (int i = 0; i < productsForCurrentMeal.Count; i++) { if (meal.TotalGramsOfFats <= 0) { break; } weightOfComponent = (int)((meal.TotalGramsOfFats * 100) / productsForCurrentMeal[i].Fat); meal.TotalGramsOfCarbs -= (weightOfComponent * productsForCurrentMeal[i].Carbs) / 100; meal.TotalGramsOfProteins -= (weightOfComponent * productsForCurrentMeal[i].Protein) / 100; meal.MealProducts.Add(productsForCurrentMeal[i], weightOfComponent); ChoosenProducts.Remove(productsForCurrentMeal[i]); break; } break; } default: { return; } } }
public string MakeDinner(IMeal meal) { return(meal.Make()); }
public void MakeDinner(IMeal meal) { meal.Make(); }
public void DeleteMeal(IMeal pMeal) { Meals.Remove(pMeal); }
public CartModel(ICart newCartService, IMeal newMealService) { cartService = newCartService; mealService = newMealService; CheckoutCart = new CartItem(); }
public JunkFoodAdapter() { this.junk = JunkFoodFactory.Create("chicken meal"); }
public MealDecorator(IMeal decoratedMeal) { this.decoratedMeal = decoratedMeal; }
private void addSecondMealToDataGrid(IMeal meal) { secondMeals.Add(meal); secondMealList.Items.Refresh(); }
private void changeMeal(IMeal meal) { CSVHandler.updateCSV(meal); }