int number;
int randomNum1= (int)(Math.random() * 12 + 1);
int randomNum2= (int)(Math.random() * 12 + 1);
try{
number = Integer.parseInt(this.txtInput.getText());
}
catch (Exception e){
JOptionPane.showMessageDialog(this, "Please input a integer.", "Error",
JOptionPane.ERROR_MESSAGE);
return;
}
if (number > randomNum1 && number < randomNum2 || number > randomNum2 && number < randomNum1){
lblRand1.setText(Integer.toString(randomNum1));
lblRand2.setText(Integer.toString(randomNum2));
lblOutput.setText("YOU WIN.");
}else
lblRand1.setText(Integer.toString(randomNum1));
lblRand2.setText(Integer.toString(randomNum2));
lblOutput.setText("YOU LOSE.");
为什么它总是显示你输了,即使我输入的是一个必须赢的数字?