Skip to content
Snippets Groups Projects
Ingredient.java 866 B
Newer Older
package mi.hdm.recipes;

import mi.hdm.exceptions.InvalidIngredientException;

public class Ingredient implements RecipeComponent {
    private Measurement unit;
Karsch Lukas's avatar
Karsch Lukas committed
    private NutritionTable nutritionTable;

    public Ingredient(Measurement unit, String name, NutritionTable nutritionTable) {
        if (name == null || name.equals("")) {
            throw new InvalidIngredientException("Can not add ingredient with name " + name);
        }
        if (nutritionTable == null) {
            throw new InvalidIngredientException("Can not add ingredient without Nutrition Table");
        }

        this.unit = unit;
        this.name = name;
        this.nutritionTable = nutritionTable;
    }
    }
    public NutritionTable getNutritionTable() {
        return nutritionTable;