Class MealComponent


public class MealComponent extends ItemComponent
  • Constructor Details

    • MealComponent

      public MealComponent(String mealName, ItemType mealType, int weight, List<IngredientComponent> ingredients, int price)
      Constructs a MealComponent with the specified attributes. Initialises the list of ingredients, calculates the initial quality, and sets the price.
      Parameters:
      mealName - - a string which is the name of the meal
      mealType - - an ItemType which represents the type of the meal
      weight - - an integer representing the weight of the meal
      ingredients - - a list of IngredientComponent objects that make up the meal
      price - - an integer representing the price of the meal
  • Method Details

    • getIngredients

      public List<IngredientComponent> getIngredients()
      Gets the list of ingredients that make up the meal.
      Returns:
      a List of IngredientComponent objects representing the ingredients in the meal
    • setIngredients

      public void setIngredients(List<IngredientComponent> ingredients)
      Sets the list of ingredients for the meal and recalculates the meal's new quality.
      Parameters:
      ingredients - - a List of IngredientComponent objects to set as the meal's ingredients
    • addIngredient

      public void addIngredient(IngredientComponent ingredient)
      Adds an ingredient to the meal and recalculates the meal's new quality.
      Parameters:
      ingredient - - an IngredientComponent object to add to the meal
    • deleteIngredient

      public void deleteIngredient(IngredientComponent ingredient)
      Deletes an ingredient from the meal and recalculates the meal's new quality.
      Parameters:
      ingredient - - an IngredientComponent object to remove from the meal
    • getQuality

      public int getQuality()
      Gets the quality of the meal.
      Returns:
      an integer representing the quality of the meal
    • setPrice

      public void setPrice(int price)
      Sets the price of the meal.
      Parameters:
      price - - an integer representing the new price of the meal
    • getPrice

      public int getPrice()
      Gets the price of the meal.
      Returns:
      an integer representing the price of the meal