@Test public void testHasItem() { final Item item = mock(Item.class); assertEquals(-1, inventory.hasItem(item)); inventory.addItem(item); assertTrue(inventory.hasItem(item) != -1); }
@Override public int hasItem(Item item) { int id = item.getId(); for (int i = 0; i < inventory.length; i++) { if (inventory[i] != null && inventory[i].getId() == id) { return i; } } return -1; }
InventoryImpl implements Inventory { @Override public int hasItem(Item item) { int id = item.getId(); for (int i = 0; i < inventory.length; i++) { if (inventory[i] != null && inventory[i].getId() == id) { return i; } } return -1; } }
InventoryImpl implements Inventory { @Override public int hasItem(Item item) { int id = item.getId(); for (int i = 0; i < inventory.length; i++) { if (inventory[i] != null && inventory[i].getId() == id) { return i; } } return -1; } InventoryImpl();  InventoryImpl(int slots);  InventoryImpl(Item[] inventory); }
InventoryImpl implements Inventory { @Override public int hasItem(Item item) { int id = item.getId(); for (int i = 0; i < inventory.length; i++) { if (inventory[i] != null && inventory[i].getId() == id) { return i; } } return -1; } InventoryImpl();  InventoryImpl(int slots);  InventoryImpl(Item[] inventory); @Override int addItem(final Item item); @Override Item getItem(int slot); @Override boolean hasFreeSlots(); @Override int hasItem(Item item); @Override Item removeItem(int slot); @Override Item removeItem(Item item); @Override Item removeItem(int slot, int amount); @Override int getCapacity(); @Override int getItemAmount(Item item); @Override void cleanup(); @Override void setCapacity(int capacity); @Override Iterator<Item> iterator(); }
InventoryImpl implements Inventory { @Override public int hasItem(Item item) { int id = item.getId(); for (int i = 0; i < inventory.length; i++) { if (inventory[i] != null && inventory[i].getId() == id) { return i; } } return -1; } InventoryImpl();  InventoryImpl(int slots);  InventoryImpl(Item[] inventory); @Override int addItem(final Item item); @Override Item getItem(int slot); @Override boolean hasFreeSlots(); @Override int hasItem(Item item); @Override Item removeItem(int slot); @Override Item removeItem(Item item); @Override Item removeItem(int slot, int amount); @Override int getCapacity(); @Override int getItemAmount(Item item); @Override void cleanup(); @Override void setCapacity(int capacity); @Override Iterator<Item> iterator();  }