@Test public void checkQuantityGetter() { TestHelper.load(); Inventory inv = new Inventory(); for (int i = 0; i < 2; i++) { assertTrue(inv.getItemQuantity(activeArray, i) == 1); } assertTrue(inv.getItemQuantity(passiveArray, 0) == 1); assertTrue(inv.getItemQuantity(generalArray, 0) == 2); assertTrue(inv.getItemQuantity(activeArray, 20) == 0); assertTrue(inv.getItemQuantity(passiveArray, 15) == 0); assertTrue(inv.getItemQuantity(generalArray, 100) == 0); assertTrue(inv.getItemQuantity("jibberish", 20) == 0); assertTrue(inv.getItemQuantity(generalArray, -10) == 0); }
public int getItemQuantity(String itemArray, int slotNumber) { final InventoryPair[] arrayToCheck; arrayToCheck = getInventory(itemArray); if (slotNumber > arrayToCheck.length || slotNumber < 0) { return 0; } return arrayToCheck[slotNumber].getQuantity(); }
Inventory { public int getItemQuantity(String itemArray, int slotNumber) { final InventoryPair[] arrayToCheck; arrayToCheck = getInventory(itemArray); if (slotNumber > arrayToCheck.length || slotNumber < 0) { return 0; } return arrayToCheck[slotNumber].getQuantity(); } }
Inventory { public int getItemQuantity(String itemArray, int slotNumber) { final InventoryPair[] arrayToCheck; arrayToCheck = getInventory(itemArray); if (slotNumber > arrayToCheck.length || slotNumber < 0) { return 0; } return arrayToCheck[slotNumber].getQuantity(); } Inventory(); }
Inventory { public int getItemQuantity(String itemArray, int slotNumber) { final InventoryPair[] arrayToCheck; arrayToCheck = getInventory(itemArray); if (slotNumber > arrayToCheck.length || slotNumber < 0) { return 0; } return arrayToCheck[slotNumber].getQuantity(); } Inventory(); int sizeOfActiveArray(); int sizeOfPassiveArray(); int sizeOfGeneralArray(); boolean isFull(String itemArray); boolean addItem(int quantity, String itemID); boolean placeItem(String itemArray, int slotNumber, String itemID, int quantity); boolean removeItem(int quantity, String itemID); boolean clearInvSlot(String itemArray, int slotNumber); boolean itemExists(String itemID); int getAmount(String itemID); String getItemID(String itemArray, int slotNumber); int getItemQuantity(String itemArray, int slotNumber); static String getItemInfo(String id, String request); static ItemType getItemType(String id); static ArmourType getArmourType(String id); Image getSprite(String id); boolean swapItem(String firstArray, int firstSlot, String secondArray, int secondSlot, boolean stack); boolean checkArrayInBounds(InventoryPair[]  array, int slotToCheck); boolean reduceActiveConsumable(int slotNumber); boolean checkActiveAmount(int playerLevel, boolean equip); static boolean checkLevelRestrictionsActive(int playerLevel, int activeAmount); boolean checkItem(String id); }
Inventory { public int getItemQuantity(String itemArray, int slotNumber) { final InventoryPair[] arrayToCheck; arrayToCheck = getInventory(itemArray); if (slotNumber > arrayToCheck.length || slotNumber < 0) { return 0; } return arrayToCheck[slotNumber].getQuantity(); } Inventory(); int sizeOfActiveArray(); int sizeOfPassiveArray(); int sizeOfGeneralArray(); boolean isFull(String itemArray); boolean addItem(int quantity, String itemID); boolean placeItem(String itemArray, int slotNumber, String itemID, int quantity); boolean removeItem(int quantity, String itemID); boolean clearInvSlot(String itemArray, int slotNumber); boolean itemExists(String itemID); int getAmount(String itemID); String getItemID(String itemArray, int slotNumber); int getItemQuantity(String itemArray, int slotNumber); static String getItemInfo(String id, String request); static ItemType getItemType(String id); static ArmourType getArmourType(String id); Image getSprite(String id); boolean swapItem(String firstArray, int firstSlot, String secondArray, int secondSlot, boolean stack); boolean checkArrayInBounds(InventoryPair[]  array, int slotToCheck); boolean reduceActiveConsumable(int slotNumber); boolean checkActiveAmount(int playerLevel, boolean equip); static boolean checkLevelRestrictionsActive(int playerLevel, int activeAmount); boolean checkItem(String id); static final String ACTIVE_ARRAY; static final int ACTIVE_SIZE; static final String PASSIVE_ARRAY; static final int PASSIVE_SIZE; static final String GENERAL_ARRAY; static final int GENERAL_SIZE; }