private Tile getTile(TilesBank bank, char ch, int pos) { int index = 0; final int bankCapacity = bank.getBankCapacity(); for (int i = 0; i < bankCapacity; i++) { final Tile tile = bank.getTile(i); if ((ch == '*' && tile.getCost() == 0) || (ch != '*' && tile.getLetter() == ch && tile.getCost() != 0)) { if (pos == index) { return tile; } else { index++; } } } throw new IllegalArgumentException("Unknown tile: " + ch + "[" + pos + "]"); }