✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.
Seguimos con el desarrollo del videojuego de rol de los ejercicios anteriores . Para diversas componentes del programa se prevé la necesidad de obtener listados de criaturas cuyo nivel sea menor o igual a un máximo dado. Con el fin de facilitar tal operación se desarrolla la siguiente subclase de
public class CreatureLevelIterator implements Iterator<Creature> {
private List<Creature> creatures;
private int pos = 0
private int maxLevel;
public CreatureLevelIterator(List<Creature> creatures,
this.creatures = creatures;
this.maxLevel = maxLevel;
}
@Override
public boolean hasNext() {
for( int i=pos; pos<creatures.size(); i++ ) {
if ( creatures.get(i).getLevel() <= maxLevel ) {
return true;
}
}
return false;
}
@Override
public Creature next() {
for( ; pos<creatures.size(); pos++ ) {
if ( creatures.get(pos).getLevel() <= maxLevel ) {
____[1]____
}
}
return null;
}
}
¿Qué instrucción habría que poner en el hueco [1]?