@Test public void testSetCapacity() { final Item item = mock(Item.class); inventory.addItem(item); inventory.setCapacity(1); assertEquals(1, inventory.getCapacity()); assertEquals(item, inventory.getItem(0)); }
@Override public void setCapacity(int capacity) { Item[] tmpInventory = new Item[capacity]; for (int i = 0; i < capacity; i++) { tmpInventory[i] = inventory[i]; } inventory = tmpInventory; }
InventoryImpl implements Inventory { @Override public void setCapacity(int capacity) { Item[] tmpInventory = new Item[capacity]; for (int i = 0; i < capacity; i++) { tmpInventory[i] = inventory[i]; } inventory = tmpInventory; } }
InventoryImpl implements Inventory { @Override public void setCapacity(int capacity) { Item[] tmpInventory = new Item[capacity]; for (int i = 0; i < capacity; i++) { tmpInventory[i] = inventory[i]; } inventory = tmpInventory; } InventoryImpl();  InventoryImpl(int slots);  InventoryImpl(Item[] inventory); }
InventoryImpl implements Inventory { @Override public void setCapacity(int capacity) { Item[] tmpInventory = new Item[capacity]; for (int i = 0; i < capacity; i++) { tmpInventory[i] = inventory[i]; } inventory = tmpInventory; } 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 setCapacity(int capacity) { Item[] tmpInventory = new Item[capacity]; for (int i = 0; i < capacity; i++) { tmpInventory[i] = inventory[i]; } inventory = tmpInventory; } 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();  }