0
這是一個超越我的想法,但我認爲這裏的某個人可以正確地說明它。基本上,我有一個循環運行,增加對象數組。我想要每個對象來保存錄制的數組。如何讓數組中的對象包含整數數組?
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));
所以我想我問我應該繼續,還是不要浪費我的時間。也請把它拼出來,就像我是一個白癡,因爲我是。
哇,我想我不能使用靜態的一切然後。謝謝你。 – user2076744 2013-02-27 05:29:38