@Test public void testRemoveItem() { TestHelper.load(); Inventory inv = new Inventory(); assertTrue(!inv.removeItem(1, "chestplate")); assertTrue(inv.removeItem(1, "potion")); assertTrue(inv.getItemID(generalArray, 0).equals("potion")); assertTrue(inv.getItemQuantity(generalArray, 0) == 1); assertTrue(inv.removeItem(1, "potion")); assertTrue(inv.getItemID(generalArray, 0).equals("emptyslot")); assertTrue(inv.getItemQuantity(generalArray, 0) == 0); assertTrue(inv.getItemID(generalArray, 1).equals("tears")); assertTrue(inv.removeItem(1, "tears")); assertTrue(inv.getItemQuantity(generalArray, 1) == 0); inv.placeItem(generalArray, 0, "Gun1", 1); assertTrue(!inv.removeItem(4, "Gun1")); assertTrue(inv.removeItem(1, "Gun1")); assertTrue(inv.checkItem("empty")); inv.placeItem(generalArray, 0, "potion", 1); assertTrue(inv.checkItem("potion")); assertTrue(!inv.checkItem("potion")); }
public boolean removeItem(int quantity, String itemID) { for (int i = 0; i < generalInventory.length; i++) { if (generalInventory[i].getItem().getID().equals(itemID) && generalInventory[i].subtractQuantity(quantity)) { if (generalInventory[i].getQuantity() == 0) { clearInvSlot(GENERAL_ARRAY, i); } return true; } } return false; }
Inventory { public boolean removeItem(int quantity, String itemID) { for (int i = 0; i < generalInventory.length; i++) { if (generalInventory[i].getItem().getID().equals(itemID) && generalInventory[i].subtractQuantity(quantity)) { if (generalInventory[i].getQuantity() == 0) { clearInvSlot(GENERAL_ARRAY, i); } return true; } } return false; } }
Inventory { public boolean removeItem(int quantity, String itemID) { for (int i = 0; i < generalInventory.length; i++) { if (generalInventory[i].getItem().getID().equals(itemID) && generalInventory[i].subtractQuantity(quantity)) { if (generalInventory[i].getQuantity() == 0) { clearInvSlot(GENERAL_ARRAY, i); } return true; } } return false; } Inventory(); }
Inventory { public boolean removeItem(int quantity, String itemID) { for (int i = 0; i < generalInventory.length; i++) { if (generalInventory[i].getItem().getID().equals(itemID) && generalInventory[i].subtractQuantity(quantity)) { if (generalInventory[i].getQuantity() == 0) { clearInvSlot(GENERAL_ARRAY, i); } return true; } } return false; } 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 boolean removeItem(int quantity, String itemID) { for (int i = 0; i < generalInventory.length; i++) { if (generalInventory[i].getItem().getID().equals(itemID) && generalInventory[i].subtractQuantity(quantity)) { if (generalInventory[i].getQuantity() == 0) { clearInvSlot(GENERAL_ARRAY, i); } return true; } } return false; } 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; }