My code:
import javafx.event.ActionEvent;
import javafx.scene.control.Label;
import java.util.Arrays;
import java.util.Random;
public class Controller {
public Label keno;
public Label loto;
public Random rd = new Random();
public void click(ActionEvent actionEvent) {
String pom = "";
int[] ken = zrebuj(10, 80);
pom = Arrays.toString(ken);
pom = pom.substring(1, pom.length() - 1);
keno.setText(pom);
ken = zrebuj(5, 35);
pom = Arrays.toString(ken);
pom = pom.substring(1, pom.length() - 1);
loto.setText(pom);
}
private int[] zrebuj(int pocet, int max) {
int[] cisla = new int[pocet];
for (int i = 0; i < cisla.length; i++) {
int tah = rd.nextInt(max) + 1;
if (jeTam(cisla, tah)==false) {
cisla[i] = tah;
}
else i--;
}
Arrays.sort(cisla);
return cisla;
}
private boolean jeTam(int[] cisla, int tah) {
for (int i = 0; i < cisla.length; i++) {
if (cisla[i] == tah) {
return true;
}
else return false;
}
}
}
My problem is, that when I start program, it crashes and it says: "Missing return statement" at the private boolean, even thought it´s right there in if statement.
Could you help me please? Thanks!
*Also, if you have any tips to make it better, just tell me in the coments ;)
Aucun commentaire:
Enregistrer un commentaire