当我在这种情况下生成问题或数字时,它似乎总是出现为0,它应该生成一个介于0和给定值AD之间的数字。在这种情况下,它是0到11,但每次只生成一个0。由于某种原因,当我将其记录到调试控制台时,AD int返回1。有什么帮助吗?
Double d = Math.random() * Max1;
O1 = d.intValue();
Log.d("BasicsPractice.java","the GenerateOperation function generated : " + O1 + " : as the number to determin the operation to be built");
if(O1 == 0) {
if(AddP == true) {
int AD = DM.AddDiff + 1;
Double d1 = Math.random() * AD;
A1 = d1.intValue();
Log.d("BasicsPractice.java","the first Addition number generated was: " + A1);
Double d5 = Math.random() * AD;
A2 = d5.intValue();
Log.d("BasicsPractice.java","the second Addition number generated was: " + A2);
Output = A1 + " + " + A2;
Log.d("BasicsPractice.java","the outputted problem was: " + Output);
OutputToProblemView();
}
答案 0 :(得分:-1)
offsetScale
返回0.0到1.0之间的数字。因此,您需要将其转换为Math.random()
。
试试这个。
int
这将生成介于0到11之间的数字。