I need to know how I can calculate a winning combination in Java is in the Primitive
The code that I show you here, is what I have done so far, I need help to be able to calculate the winning combination, since it is costing me a lot to understand it and be able to do it, I was doing it by myself, if someone can help me, I would greatly appreciate it
The class where it is in CalculateWinningCombination is that part that I don't know how to do
public void init(){
System.out.println("***** PRIMITIVA ******");
int[] apuesta = introducirApuesta();
int[] combinacionGanadora = calcularCombinacionGanadora();
if (combinacionGanadora!=null) {
System.out.println("La combinacion ganadora es: ");
for (int i = 0; i < combinacionGanadora.length - 1; i++) {
System.out.print(combinacionGanadora[i] + " ");
}
System.out.println("Reintegro: " + combinacionGanadora[combinacionGanadora.length - 1]);
}
int premio = comprobarAciertos(apuesta, combinacionGanadora);
System.out.println("Tu premio es: "+premio+" €");
}
public int[] introducirApuesta(){
Scanner input=new Scanner(System.in);
int random=(int)(Math.random()*0+9);
System.out.println("Introduce tu apuesta");
int [] apuesta=new int[7];
for (int i=0;i<apuesta.length;i++){
apuesta[i]=input.nextInt();
}
System.out.println("La Apuesta introducida es");
System.out.println(Arrays.toString(apuesta)+" "+random);
return apuesta;
}
public int[] calcularCombinacionGanadora(){
int [] combinacion=new int[7];
Random rnd=new Random();
return combinacion;
}
First of all, I agree with one of the comments,
It will always return 9, also, I'm not sure what the point of this random number is in the enter bet function.
As for calculating the winning combination, from what I understand it should come down to getting a combination of 7 random numbers within a certain range.
For example, suppose they must be integers between 1 and 49. This could be a solution.