My colleagues good night, I did a math game.
the random numbers can show it in the interface, but it does not compare the user's number with the results scheduled
I can not make a comparison.
If I put the number just to appear on the screen, it luckened the number, but not on the console.
private void verificarResultadoActionPerformed(java.awt.event.ActionEvent evt){
Random rand = new Random();
int numero1 = rand.nextInt(2)+2 ;
int numero2 = rand.nextInt(9)+2 ;
int resultprogramado = (numero1*numero2);
int respUsuario = Integer.parseInt(respostaUsuario.getText());
if ( respUsuario == resultprogramado) {
System.out.printf("Resposta certa!%n %d x %d = %d", numero1, numero2, (numero1 * numero2));
} else {
System.out.printf("Resposta errada!%n %d x %d = %d", numero1, numero2, (numero1 * numero2));
}
gerarNovaOperacao();
}
private void gerarNovaOperacao() {
Random rand = new Random();
int numero1 = rand.nextInt(2)+2 ;
int numero2 = rand.nextInt(9)+2 ;
int resultprogramado = numero1 * numero2;
telaX.setText(numero1+ "x" +numero2);
respostaUsuario.setText("");
respostaUsuario.requestFocus();
}