1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
@Override
public List<Integer> simuleJet(Integer nombreDe, boolean chanceAuxDes) throws JetDeException{
if(nombreDe < 0) {
Object[] params = {nombreDe};
throw new JetDeException(params, "jet.de.calcul.proba.simulation.nombre.negatif");
}
List<Integer> orderList =
chanceAuxDes?scoresPossibles.stream().sorted(Comparator.reverseOrder()).toList()
:scoresPossibles.stream().sorted(Comparator.naturalOrder()).toList();
int index = 0;
List<Integer> lReturn = new ArrayList<>();
for(int i = 0; i < nombreDe; i++) {
lReturn.add(orderList.get(index));
index++;
if(index == orderList.size()) {
index = 0;
}
}
return lReturn.stream().sorted(Comparator.reverseOrder()).toList();
} |
Partager