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;
}
----------------解决方案--------------------------------------------------------
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 &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.
----------------解决方案--------------------------------------------------------