//'+'操作
if (temp == buttonAdd)
{
switch (prekey)
{
case 0:
answerd += Double.parseDouble(textAnswer.getText());
break;
case 1:
answerd -= Double.parseDouble(textAnswer.getText());
break;
case 2:
answerd *= Double.parseDouble(textAnswer.getText());
break;
case 3:
if (Double.parseDouble(textAnswer.getText()) == 0)
{
textAnswer.setText("除数不能为零");
clickable = false;
} else
answerd /= Double.parseDouble(textAnswer.getText());
break;
default:
answerd = Double.parseDouble(textAnswer.getText());
}
textAnswer.setText("");
prekey = key = 0;
}
中为什么要 判断那么多,只判断一个 0 可不可以