package com.mealplanner;
import java.util.*;
public class Recipe {
String name = null;
String category= null;
double costOfRecipe;
int numberOfIngredients = 0;
HashMap<Ingredient, Double> recipe = new HashMap();
/*
ArrayList <Ingredient> ingredients = new ArrayList<Ingredient>();
ArrayList<Double> amounts = new ArrayList<Double>();
*/
public Recipe(){}
public Recipe(String recipeName){
Ingredient blankIngredient = new Ingredient("blankIngredient");
name = recipeName;
//name = "BlankRecipe";
category = "Blank";
//costOfRecipe = 0d;
numberOfIngredients = 1;
recipe.put(blankIngredient, 0d);
}
public Recipe(String name, String category, Ingredient ing1Name, double ing1Amount,
Ingredient ing2Name, double ing2Amount,Ingredient ing3Name, double ing3Amount ){
this.name = name;
this.category = category;
recipe.put(ing1Name, ing1Amount);
recipe.put(ing2Name, ing2Amount);
recipe.put(ing3Name, ing3Amount);
numberOfIngredients = 3;
costOfRecipe = calculateCostOfRecipe(recipe);
}
public String getName(){
return name;
}
public int getNumberOfIngredients() {
return numberOfIngredients;
}
public Set<Ingredient> getRecipe() {
return recipe.keySet();
}
public static double calculateCostOfRecipe(HashMap<Ingredient, Double> recipe){
// loops through the hashmap and multiplies the amount and unit price
double recipeCost = 0;
double multiplication = 0;
for (Map.Entry<Ingredient, Double> entry: recipe.entrySet()) {
multiplication = (entry.getKey().pricePerUnit) * entry.getValue();
recipeCost += multiplication;
}
return recipeCost;
}
void add1Ingredient(Ingredient ing, Double amount){
recipe.put(ing, amount);
costOfRecipe = calculateCostOfRecipe(recipe);
}
//Constructors
public Recipe(String name, String category, Ingredient ing1Name, double ing1Amount,
Ingredient ing2Name, double ing2Amount){
this.name = name;
this.category = category;
recipe.put(ing1Name, ing1Amount);
recipe.put(ing2Name, ing2Amount);
numberOfIngredients = 2;
costOfRecipe = calculateCostOfRecipe(recipe);
}
public Recipe(String name, String category, Ingredient ing1Name, double ing1Amount,
Ingredient ing2Name, double ing2Amount,Ingredient ing3Name, double ing3Amount, Ingredient ing4Name, double ing4Amount ){
this.name = name;
this.category = category;
recipe.put(ing1Name, ing1Amount);
recipe.put(ing2Name, ing2Amount);
recipe.put(ing3Name, ing3Amount);
recipe.put(ing4Name, ing4Amount);
numberOfIngredients = 4;
costOfRecipe = calculateCostOfRecipe(recipe);
}
//Constructors
public Recipe(String name, String category, Ingredient ing1Name, double ing1Amount,
Ingredient ing2Name, double ing2Amount,Ingredient ing3Name, double ing3Amount,
Ingredient ing4Name, double ing4Amount, Ingredient ing5Name, double ing5Amount ){
this.name = name;
this.category = category;
recipe.put(ing1Name, ing1Amount);
recipe.put(ing2Name, ing2Amount);
recipe.put(ing3Name, ing3Amount);
recipe.put(ing4Name, ing4Amount);
recipe.put(ing5Name, ing5Amount);
numberOfIngredients = 5;
costOfRecipe = calculateCostOfRecipe(recipe);
}
public Recipe(String name, String category, Ingredient ing1Name, double ing1Amount,
Ingredient ing2Name, double ing2Amount,Ingredient ing3Name, double ing3Amount,
Ingredient ing4Name, double ing4Amount, Ingredient ing5Name, double ing5Amount,
Ingredient ing6Name, double ing6Amount ){
this.name = name;
this.category = category;
recipe.put(ing1Name, ing1Amount);
recipe.put(ing2Name, ing2Amount);
recipe.put(ing3Name, ing3Amount);
recipe.put(ing4Name, ing4Amount);
recipe.put(ing5Name, ing5Amount);
recipe.put(ing6Name, ing6Amount);
numberOfIngredients = 6;
costOfRecipe = calculateCostOfRecipe(recipe);
}
public Recipe(String name, String category, Ingredient ing1Name, double ing1Amount,
Ingredient ing2Name, double ing2Amount,Ingredient ing3Name, double ing3Amount,
Ingredient ing4Name, double ing4Amount, Ingredient ing5Name, double ing5Amount,
Ingredient ing6Name, double ing6Amount, Ingredient ing7Name, double ing7Amount ){
this.name = name;
this.category = category;
recipe.put(ing1Name, ing1Amount);
recipe.put(ing2Name, ing2Amount);
recipe.put(ing3Name, ing3Amount);
recipe.put(ing4Name, ing4Amount);
recipe.put(ing5Name, ing5Amount);
recipe.put(ing6Name, ing6Amount);
recipe.put(ing7Name, ing7Amount);
numberOfIngredients = 7;
costOfRecipe = calculateCostOfRecipe(recipe);
}
public Recipe(String name, String category, Ingredient ing1Name, double ing1Amount,
Ingredient ing2Name, double ing2Amount,Ingredient ing3Name, double ing3Amount,
Ingredient ing4Name, double ing4Amount, Ingredient ing5Name, double ing5Amount,
Ingredient ing6Name, double ing6Amount, Ingredient ing7Name, double ing7Amount,
Ingredient ing8Name, double ing8Amount) {
this.name = name;
this.category = category;
recipe.put(ing1Name, ing1Amount);
recipe.put(ing2Name, ing2Amount);
recipe.put(ing3Name, ing3Amount);
recipe.put(ing4Name, ing4Amount);
recipe.put(ing5Name, ing5Amount);
recipe.put(ing6Name, ing6Amount);
recipe.put(ing7Name, ing7Amount);
recipe.put(ing8Name, ing8Amount);
numberOfIngredients = 8;
costOfRecipe = calculateCostOfRecipe(recipe);
}
public Recipe(String name, String category, Ingredient ing1Name, double ing1Amount,
Ingredient ing2Name, double ing2Amount,Ingredient ing3Name, double ing3Amount,
Ingredient ing4Name, double ing4Amount, Ingredient ing5Name, double ing5Amount,
Ingredient ing6Name, double ing6Amount, Ingredient ing7Name, double ing7Amount,
Ingredient ing8Name, double ing8Amount, Ingredient ing9Name, double ing9Amount) {
this.name = name;
this.category = category;
recipe.put(ing1Name, ing1Amount);
recipe.put(ing2Name, ing2Amount);
recipe.put(ing3Name, ing3Amount);
recipe.put(ing4Name, ing4Amount);
recipe.put(ing5Name, ing5Amount);
recipe.put(ing6Name, ing6Amount);
recipe.put(ing7Name, ing7Amount);
recipe.put(ing8Name, ing8Amount);
recipe.put(ing9Name, ing9Amount);
numberOfIngredients = 9;
costOfRecipe = calculateCostOfRecipe(recipe);
}
public Recipe(String name, String category, Ingredient ing1Name, double ing1Amount,
Ingredient ing2Name, double ing2Amount,Ingredient ing3Name, double ing3Amount,
Ingredient ing4Name, double ing4Amount, Ingredient ing5Name, double ing5Amount,
Ingredient ing6Name, double ing6Amount, Ingredient ing7Name, double ing7Amount,
Ingredient ing8Name, double ing8Amount, Ingredient ing9Name, double ing9Amount,
Ingredient ing10Name, double ing10Amount) {
this.name = name;
this.category = category;
recipe.put(ing1Name, ing1Amount);
recipe.put(ing2Name, ing2Amount);
recipe.put(ing3Name, ing3Amount);
recipe.put(ing4Name, ing4Amount);
recipe.put(ing5Name, ing5Amount);
recipe.put(ing6Name, ing6Amount);
recipe.put(ing7Name, ing7Amount);
recipe.put(ing8Name, ing8Amount);
recipe.put(ing9Name, ing9Amount);
recipe.put(ing10Name, ing10Amount);
numberOfIngredients = 10;
costOfRecipe = calculateCostOfRecipe(recipe);
}
}