我如何为我的代码设置一个限制问题

时间:2019-06-17 17:53:45

标签: java android

我如何为此设置一个极限问题

 public void setQuestion() {
        Random rand = new Random();
    int value1 = rand.nextInt(100-10) + 10;
    int value2 = rand.nextInt(20-2) + 2;

        int randomquestion = rand.nextInt(4);
        if (randomquestion == 1) {
            question.setText("What is " + value1 + "+" + value2 + " ? ");
            expected = "" + (value1 + value2);
        } else if (randomquestion == 2) {
            question.setText("What is " + value1 + "-" + value2 + " ? ");
            expected = "" + (value1 - value2);
        } else if (randomquestion == 3) {
            question.setText("What is " + value1 + "x" + value2 + " ? ");
            expected = "" + (value1 * value2);
        } else {
            question.setText("What is " + value1 + "÷" + value2 + "?");
            expected = "" + (value1 / value2);
        }

    }

我希望它只能提出10个问题,并会结束活动

0 个答案:

没有答案