@Test public void testCleanup() { final Item item = MockFactory.mockItem(1, 0); final Item item2 = MockFactory.mockItem(2, 1); inventory.addItem(item); inventory.addItem(item2); inventory.cleanup(); assertEquals(-1, inventory.hasItem(item)); assertThat(inventory.hasItem(item2), not(equalTo(-1))); }
@Override public void cleanup() { for (int i = inventory.length - 1; i >= 0; i--) { if (inventory[i] != null && inventory[i].getAmount() == 0) { inventory[i] = null; } } }
InventoryImpl implements Inventory { @Override public void cleanup() { for (int i = inventory.length - 1; i >= 0; i--) { if (inventory[i] != null && inventory[i].getAmount() == 0) { inventory[i] = null; } } } }
InventoryImpl implements Inventory { @Override public void cleanup() { for (int i = inventory.length - 1; i >= 0; i--) { if (inventory[i] != null && inventory[i].getAmount() == 0) { inventory[i] = null; } } } InventoryImpl();  InventoryImpl(int slots);  InventoryImpl(Item[] inventory); }
InventoryImpl implements Inventory { @Override public void cleanup() { for (int i = inventory.length - 1; i >= 0; i--) { if (inventory[i] != null && inventory[i].getAmount() == 0) { inventory[i] = null; } } } 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 void cleanup() { for (int i = inventory.length - 1; i >= 0; i--) { if (inventory[i] != null && inventory[i].getAmount() == 0) { inventory[i] = null; } } } 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();  }