Class Inventory

java.lang.Object
ch.epfl.cs107.play.areagame.handler.Inventory

public abstract class Inventory extends Object
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static interface 
     
    static interface 
    Can be implemented by all Inventory holder.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Inventory(String... pocketNames)
    Default Inventory Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    addPocketItem(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 pocket
    boolean
    Boolean accessor to this inventory which indicate if one pocket possess the given object
    protected void
    Notify the listener about the given pocket update
    boolean
    removePocketItem(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 pocket
    void
    Add a listener to this inventory

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Inventory

      public Inventory(String... pocketNames)
      Default Inventory Constructor
      Parameters:
      pocketNames - (Array of String), not null
  • Method Details

    • addPocketItem

      public boolean addPocketItem(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 pocket
      Parameters:
      item - (InventoryItem): item to add, not null
      quantity - (int): quantity of the item to add
      Returns:
      (boolean): true if the given quantity of the given item has been added
    • removePocketItem

      public boolean removePocketItem(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 pocket
      Parameters:
      item - (InventoryItem): item to remove, not null
      quantity - (int): quantity of the item to remove
      Returns:
      (boolean): true if the given quantity of the given item has been removed
    • setGui

      public void setGui(Inventory.GUI gui)
      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

      public boolean contains(InventoryItem item)
      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