public Ingredient(string name, IngredientType ingredientType, float protein, float fats, float carbs, float vitamins, float minerals) { this.ingredientType = ingredientType; this.name = name; organicParts = new OrganicParts(protein, fats, carbs, vitamins, minerals); // ingredientType.ingredients.Add(this); }
public WeightedIngredient(Ingredient ingredient, float weight) { this.weight = weight; this.ingredient = ingredient; weightedOrgParts = ingredient.organicParts * weight; // ingredient.wIngredients.Add(this); }
public OrganicParts sumRecipes() { OrganicParts orgParts = new OrganicParts(0, 0, 0, 0, 0); foreach (Recipe rec in recipes) { orgParts += rec.SumIngredients(); } return(orgParts); }
public OrganicParts SumIngredients() { OrganicParts orgParts = new OrganicParts(0, 0, 0, 0, 0); foreach (WeightedIngredient weighIng in wIngredients) { orgParts += weighIng.weightedOrgParts; } return(orgParts); }
public static OrganicParts operator +(OrganicParts orgParts1, OrganicParts orgParts2) { float proteinSum = orgParts1.proteins + orgParts2.proteins; float fatsSum = orgParts1.fats + orgParts2.fats; float carbsSum = orgParts1.carbs + orgParts2.carbs; float vitaminsSum = orgParts1.vitamins + orgParts2.vitamins; float mineralsSum = orgParts1.minerals + orgParts2.minerals; OrganicParts sum = new OrganicParts(proteinSum, fatsSum, carbsSum, vitaminsSum, mineralsSum); return(sum); }
public static OrganicParts operator *(OrganicParts orgParts1, float multiplier) { multiplier /= 100; float proteinSum = orgParts1.proteins * multiplier; float fatsSum = orgParts1.fats * multiplier; float carbsSum = orgParts1.carbs * multiplier; float vitaminsSum = orgParts1.vitamins * multiplier; float mineralsSum = orgParts1.minerals * multiplier; OrganicParts sum = new OrganicParts(proteinSum, fatsSum, carbsSum, vitaminsSum, mineralsSum); return(sum); }