me aparece esta excepción, relacionada con el 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)
Dejo a continuación el código donde está la generación del número aleatorio, a ver si alguien encuentra algún tipo de anomalía, me parece estar bien.
Random aleatoria = new Random();
int i = aleatoria.nextInt(this.numGrupos);
--------------Añado el método----------------
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;
}
------------------vista desde debugger-----------------------
while
)at gestorgrupos.Grupo.opcionAleatoria(Grupo.java:78)