Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sample;
- 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 rn = new Random();
- public void losuj(ActionEvent event) {
- 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 = rn.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;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement