Class MealComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.items.ItemComponent
com.csse3200.game.components.items.MealComponent
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionMealComponent
(String mealName, ItemType mealType, int weight, List<IngredientComponent> ingredients, int price) Constructs a MealComponent with the specified attributes. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addIngredient
(IngredientComponent ingredient) Adds an ingredient to the meal and recalculates the meal's new quality.void
deleteIngredient
(IngredientComponent ingredient) Deletes an ingredient from the meal and recalculates the meal's new quality.Gets the list of ingredients that make up the meal.int
getPrice()
Gets the price of the meal.int
Gets the quality of the meal.void
setIngredients
(List<IngredientComponent> ingredients) Sets the list of ingredients for the meal and recalculates the meal's new quality.void
setPrice
(int price) Sets the price of the meal.Methods inherited from class com.csse3200.game.components.items.ItemComponent
getItemId, getItemName, getItemType, getTexturePath, getWeight
Methods inherited from class com.csse3200.game.components.Component
create, dispose, earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
-
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 mealmealType
- - an ItemType which represents the type of the mealweight
- - an integer representing the weight of the mealingredients
- - a list of IngredientComponent objects that make up the mealprice
- - an integer representing the price of the meal
-
-
Method Details
-
getIngredients
Gets the list of ingredients that make up the meal.- Returns:
- a List of IngredientComponent objects representing the ingredients in the meal
-
setIngredients
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
Adds an ingredient to the meal and recalculates the meal's new quality.- Parameters:
ingredient
- - an IngredientComponent object to add to the meal
-
deleteIngredient
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
-