Class InventoryManager


  • public class InventoryManager
    extends java.lang.Object
    Class for working with Inventory (fully static)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.util.LinkedList<Item> inventory  
    • Method Summary

      Modifier and Type Method Description
      static void addItem​(Item item)
      Increase multiplicity of items, if exists in Inventory, or add to List
      static Item findItemByName​(java.lang.String name)
      Return Item, if exists in List with this Name
      static void flushInventory()
      Deletes all items from Inventory
      static java.util.LinkedList<Item> getInventory()  
      static boolean isInInventory​(Item item)
      Checks, if item in Inventory
      static boolean removeItem​(Item item, int count)
      Removes count of Item, if it possible
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • inventory

        private static java.util.LinkedList<Item> inventory
    • Constructor Detail

      • InventoryManager

        public InventoryManager()
    • Method Detail

      • addItem

        public static void addItem​(Item item)
        Increase multiplicity of items, if exists in Inventory, or add to List
        Parameters:
        item - Item to add to inventory
      • flushInventory

        public static void flushInventory()
        Deletes all items from Inventory
      • isInInventory

        public static boolean isInInventory​(Item item)
        Checks, if item in Inventory
        Parameters:
        item - Item to check
        Returns:
        true if is in List, false if not
      • removeItem

        public static boolean removeItem​(Item item,
                                         int count)
        Removes count of Item, if it possible
        Parameters:
        item - Item to remove
        count - Count of this Item
        Returns:
        true if successful, false if not
      • getInventory

        public static java.util.LinkedList<Item> getInventory()
      • findItemByName

        public static Item findItemByName​(java.lang.String name)
        Return Item, if exists in List with this Name
        Parameters:
        name - Name of Item
        Returns:
        Item if exists, null if not