I am a student of 1 semester of ing. of systems, I have to make a game of "point and fame" in java and I am quite entangled to tell the truth. The game tries to generate 4 random numbers that are not repeated, the user will try to guess what the number is. If you hit a number, but it is not in the correct position it is a point, and if you hit the number in the correct position is a fame, this is basically.
Now the problem is that I do not know how to store the numbers generated by the code to be able to compare them with the ones that the user enters, I have this:
package prueba;
import java.util.Random;
import java.util.Arrays;
/**
*
* @author Alvaro
*/
public class Prueba {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int n=4; //numeros aleatorios
int k=n; //auxiliar;
int[] numeros=new int[n];
int[] resultado=new int[n];
Random rnd=new Random();
int res;
//se rellena una matriz ordenada del 1 al 9(1..n)
for(int i=0;i<n;i++){
numeros[i]=i+1;
}
for(int i=0;i<n;i++){
res=rnd.nextInt(k);
resultado[i]=numeros[res];
numeros[res]=numeros[k-1];
k--;
}
//se imprime el resultado;
System.out.println("El resultado de la matriz es:");
for(int i=0;i<n;i++){
int na1=resultado[i],na2=resultado[i],na3=resultado[i],na4=resultado[i];
System.out.println(resultado[i]);
System.out.println(na1+"xxx"+na2+"xxx"+na3+"xxx"+na4);
}
}
}
I really appreciate the help.