这是一个超出我想象的想法,但我认为这里有人可以正确地说明它。基本上,我运行了一个递增对象数组的 for 循环。我希望每个对象都保存记录的数组。
static RollDice p1,p2,p3,p4;
static RollDice[] Players = new RollDice[]{p1,p2,p3,p4};
for (int a=0;a<4;a++){
for(int b =0;b<4;b++){
roll = Math.random()*5;
roll = Math.round(roll);
roll = roll+1;
Players[a].Numbers[b]=(int)roll;
System.out.println("You have rolled a: "+roll);
}
//This prints four numbers in an array for each value of a.
System.out.println(Arrays.toString(Players[a].Numbers));
//This is SUPPOSED to call the numbers recorded for that object. I had it as Players[#].Numbers before, but of course that didn't work either.
System.out.println(Arrays.toString(p2.Numbers));
所以我想我是在问我是否应该继续,或者只是不浪费我的时间。也请像我是个白痴一样拼写出来,因为我是。