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.");
爲什麼它總是顯示你失去即使我的輸入是一個必須贏得的數字?條件陳述不工作Java
什麼條件貢獻一場勝利? – root
這是Java和**不** ** JAVA。 –