Interface Inventory

All Known Implementing Classes:
Backpack, InventoryComponent

public interface Inventory
Inventory interface, limiting some basic functions of inventory
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    add(int id)
    Add an item with a specified id
    boolean
    add(int id, int num)
    Add several of this item
    boolean
    add(String itemName)
    Add an item with a specified id
    boolean
    add(String itemName, int num)
    Add several of this item
    boolean
    contains(int id)
    Check if a specific item is present in the backpack
    boolean
    contains(String itemName)
    Check if a specific item is present in the backpack
    int
    count(int id)
    Quantity of a specific item
    int
    count(String itemName)
    Quantity of a specific item
     
    boolean
    remove(int id)
    remove a specified item
    boolean
    remove(int id, int num)
     
    boolean
    remove(String itemName)
    remove a specified item
    boolean
    remove(String itemName, int num)
     
  • Method Details

    • contains

      boolean contains(int id)
      Check if a specific item is present in the backpack
      Parameters:
      id - item id
      Returns:
      true if the quantity of the item in stock is greater than zero
    • contains

      boolean contains(String itemName)
      Check if a specific item is present in the backpack
      Parameters:
      itemName - item name
      Returns:
      true if the quantity of the item in stock is greater than zero
    • count

      int count(int id)
      Quantity of a specific item
      Parameters:
      id - item id
      Returns:
      the quantity of the item or -1 if the item id is not exist.
    • count

      int count(String itemName)
      Quantity of a specific item
      Parameters:
      itemName - item name
      Returns:
      the quantity of the item or -1 if the item name is not exist.
    • add

      boolean add(int id)
      Add an item with a specified id
      Parameters:
      id - item id
      Returns:
      true if add successfully
    • add

      boolean add(int id, int num)
      Add several of this item
      Parameters:
      id - item id
      num - the number of the added item
      Returns:
    • add

      boolean add(String itemName)
      Add an item with a specified id
      Parameters:
      itemName - item name
      Returns:
      true if add successfully
    • add

      boolean add(String itemName, int num)
      Add several of this item
      Parameters:
      itemName - item name
      num - the number of the added item
      Returns:
    • remove

      boolean remove(int id)
      remove a specified item
      Parameters:
      id - item id
      Returns:
      true if remove successfully
    • remove

      boolean remove(String itemName)
      remove a specified item
      Parameters:
      itemName - item name
      Returns:
      true if remove successfully
    • remove

      boolean remove(int id, int num)
    • remove

      boolean remove(String itemName, int num)
    • getInStockItemIds

      List<Integer> getInStockItemIds()