Class Inventory
java.lang.Object
ch.epfl.cs107.play.areagame.handler.Inventory
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic interfaceCan be implemented by all Inventory holder. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddPocketItem(InventoryItem item, int quantity) Add if possible the given quantity of the given item into the given pocket If done, notify listener of the change into the pocketbooleancontains(InventoryItem item) Boolean accessor to this inventory which indicate if one pocket possess the given objectprotected voidnotifyPocketUpdated(int id) Notify the listener about the given pocket updatebooleanremovePocketItem(InventoryItem item, int quantity) Remove if possible the given quantity of the given item from the given pocket If done, notify listener of the change into the pocketvoidsetGui(Inventory.GUI gui) Add a listener to this inventory
-
Constructor Details
-
Inventory
Default Inventory Constructor- Parameters:
pocketNames- (Array of String), not null
-
-
Method Details
-
addPocketItem
Add if possible the given quantity of the given item into the given pocket If done, notify listener of the change into the pocket- Parameters:
item- (InventoryItem): item to add, not nullquantity- (int): quantity of the item to add- Returns:
- (boolean): true if the given quantity of the given item has been added
-
removePocketItem
Remove if possible the given quantity of the given item from the given pocket If done, notify listener of the change into the pocket- Parameters:
item- (InventoryItem): item to remove, not nullquantity- (int): quantity of the item to remove- Returns:
- (boolean): true if the given quantity of the given item has been removed
-
setGui
Add a listener to this inventory- Parameters:
gui- (GUI): The listener to add
-
notifyPocketUpdated
protected void notifyPocketUpdated(int id) Notify the listener about the given pocket update- Parameters:
id- (int): Pocket id
-
contains
Boolean accessor to this inventory which indicate if one pocket possess the given object- Parameters:
item- (InventoryItem): the given object to check if contained, may be null- Returns:
- (boolean): True if one pocket possess the given object
-