出于某种原因,只有数组中的最终值被赋值......这是为什么呢?
public void openFrameScores() {
int x = 0;
int y = 0;
int total = 0;
for(int i = 0; i < framesToBowl; i++) {
scores = new int[2][framesToBowl];
x = (int)(Math.random() * 9);
if(x == 0) y = (int)(Math.random() * 9);
else y = (int)(Math.random() * (9 - x));
scores[0][i] = x;
scores[1][i] = y;
}
for(int i = 0; i < framesToBowl; i++) {
total = total + scores[0][i] + scores[1][i];
System.out.println("Frame: " + i + ", ball 1 = " + scores[0][i] +
", ball 2 = " + scores[1][i] + ", total score = " + total);
}
}
------------------------------------------------
Frame: 0, ball 1 = 0, ball 2 = 0, total score = 0
Frame: 1, ball 1 = 0, ball 2 = 0, total score = 0
Frame: 2, ball 1 = 0, ball 2 = 0, total score = 0
Frame: 3, ball 1 = 0, ball 2 = 0, total score = 0
Frame: 4, ball 1 = 0, ball 2 = 0, total score = 0
Frame: 5, ball 1 = 0, ball 2 = 0, total score = 0
Frame: 6, ball 1 = 0, ball 2 = 0, total score = 0
Frame: 7, ball 1 = 0, ball 2 = 0, total score = 0
Frame: 8, ball 1 = 0, ball 2 = 0, total score = 0
Frame: 9, ball 1 = 6, ball 2 = 1, total score = 7