2015-05-21 30 views
-1

这种方法的目的是,我拥有一个充满泡泡的对象二维数组,我竟将阵列中的一切不为0的颜色值下来,离开列顶部的颜色为0。
目前它变成每一个现场与我想的是我在想念一个小逻辑错误一个0值的泡沫,但我一直在努力,现在为3天,无法看到我的问题。 *澄清:myBoard初始化为新的Bubble [15] [15];与泡沫构造函数(INT颜色,诠释行,诠释山口)换挡部件以特定方式

public void shiftBoardDown() { 

    int currentC = 0; 

    while(currentC < 15){ 
     Bubble [] temp = new Bubble [15]; 
     int hits = 14; 

     for(int i = 14; i <= 0; i--){ 
      if(this.myBoard[i][currentC].getColor() != 0){ 
       temp[hits] = new Bubble(this.myBoard[i][currentC].getColor(), hits, currentC); 
       hits--; 
      } 
     } 

     while(hits >= 0){ 
      temp[hits] = new Bubble(0, hits, currentC); 
      hits--; 
     } 
     for(int r = 0; r < 15; r++){ 
      this.myBoard[r][currentC] = temp[r]; 
     } 
     currentC++; 
    } 

} 
+0

这是什么语言?适当标记问题。 – deceze

回答

1

我猜

if(this.myBoard[i][currentC].getColor() != 0) 

永远不会被触发,下面进入循环与hits==14

while(hits >= 0){ 
    temp[hits] = new Bubble(0, hits, currentC); 
    hits--; 
} 

从14至0包容这种情况下hits运行在温度中的对应条目设置为颜色0 Bubble

在第一回路设置上`hits--”一个破发点,以确认它是否曾经被触发。

我不能告诉,因为我可以的this.myBoard[i]状态如何进入功能。

+0

谢谢你是对的,我的问题是在第一个循环中,我意外地做了<而不是> – user2016588