Class AbstractFood
java.lang.Object
com.csse3200.game.inventory.items.AbstractItem
com.csse3200.game.inventory.items.ConsumableItem
com.csse3200.game.inventory.items.food.AbstractFood
- Direct Known Subclasses:
Foods.Apple
,Foods.Candy
,Foods.Carrot
,Foods.ChickenLeg
,Foods.CloudCookie
,Foods.CloudCupcake
,Foods.CottonCloud
,Foods.FriedFish
,Foods.Meat
,Foods.Milk
,Foods.Shrimp
,Foods.Sushi
The AbstractFood class manages the amount of hunger points (provided from food items) is added to the hunger bar
This classes applies the effect of the nutrition points towards the animal hunger bar
-
Field Summary
Fields inherited from class com.csse3200.game.inventory.items.AbstractItem
description, itemCode, limit, name, onlyCombatItem, onlyMapItem, quantity
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractFood
(String name, int itemCode, int limit, int quantity, int feedingAmount) Constructs a AbstractFood with the specified uses -
Method Summary
Modifier and TypeMethodDescriptionvoid
useItem
(ItemUsageContext context) Uses the food by applying its effects and decreasing the number of uses If no uses are left the potion will not apply the effect and will throw an errorMethods inherited from class com.csse3200.game.inventory.items.AbstractItem
add, getDescription, getItemCode, getLimit, getName, getQuantity, getTexturePath, isEmpty, numAddable, onlyCombatItem, onlyMapItem, setDescription, setTexturePath
-
Constructor Details
-
AbstractFood
Constructs a AbstractFood with the specified uses- Parameters:
name
- the name of the itemitemCode
- the item codelimit
- the stack limit of the itemquantity
- the initial quantity for this item
-
-
Method Details
-
useItem
Uses the food by applying its effects and decreasing the number of uses If no uses are left the potion will not apply the effect and will throw an error- Overrides:
useItem
in classConsumableItem
- Parameters:
context
- the context in which the item is used (contains a Player to use on)
-