当前位置: 代码迷 >> Java相关 >> [求助]help help assignment
  详细解决方案

[求助]help help assignment

热度:729   发布时间:2004-05-06 21:51:00.0
[求助]help help assignment

In one of the steps of the assignment, in says this: Write a method in the Board Class which is given a character c. The method should determine if any of the rows in the board contain a sequence of 4 or more of the given characters (e.g. if we have "connected four"). The method should return true if such a sequence exists in the board and false otherwise.

NOTE: The whole assignment is about creating a board , the getRow(int i) will return the index of i row as a String, and getSequence(char c,int i) is just return a String that contains i number of char c.

what I wrote didnt work, can any one tell me why???

public boolean isConnectedFour(char c){ boolean notStop = true; if(getRow(0).length()>=FOUR){ for(int i = 0; i<size && notStop; i++){ int index =getRow(i).indexOf(c); if(getRow(i).substring(index,index+4).equals(getSequence(c,FOUR))){ notStop = false; return true; } else return false;

}

} else return false;

}

搜索更多相关的解决方案: assignment  help  

----------------解决方案--------------------------------------------------------
Oh, I just forgot, FOUR is a static final variable. as public static final int FOUR = 4;
----------------解决方案--------------------------------------------------------
Can you describe it more clearly?Do you mean if a String contain FOUR then return true?And some ESC char in you code like &amp;gt;  dose it inputed by mistake?
----------------解决方案--------------------------------------------------------

this is just getting strange, i dont know why that happens to my code when i put them in fourm, but anyway, i sovled that problem already

cheers.


----------------解决方案--------------------------------------------------------
  相关解决方案