I get this exception, related to Random.
Exception in thread "main" java.lang.IllegalArgumentException: bound must be positive
at java.util.Random.nextInt(Random.java:388)
at gestorgrupos.Grupo.opcionAleatoria(Grupo.java:78)
at gestorgrupos.Generador.generarListaOpciones(Generador.java:125)
at principal.Principal.main(Principal.java:77)
I leave below the code where the generation of the random number is, to see if someone finds some kind of anomaly, I think it's fine.
Random aleatoria = new Random();
int i = aleatoria.nextInt(this.numGrupos);
-------------- I add the method ----------------
public String generarListaOpciones() {
String texto = "";
Random aleatoria = new Random();
int i = aleatoria.nextInt(this.numGrupos);
int j = 1;
IElegible opcionAleato;
texto += "Orden de las opciones:";
while (this.numGrupos > 0) {
opcionAleato = this.grupos[i].opcionAleatoria();
String mensaje = opcionAleato.opcion();
texto += "nº" + j + " - Grupo: " + this.grupos[i].nombreCompleto() + "Opción: - "
+ this.grupos[i].opcionAleatoria().opcion() + mensaje;
this.grupos[i].eliminaOpcion(opcionAleato);
if (this.grupos[i].opciones.length == 0) {
int posicionFinal = numGrupos-1;
this.grupos[i] = this.grupos[posicionFinal];
this.numGrupos--;
}
j++;
}
return texto;
}
------------------ view from debugger -----------------------