Java: checkPositionRow
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/13692902/gamelogic-x-in-a-row-game">GameLogic, x in a row game</a>  </p>
</blockquote>



<p>Description of checkPositionRow:</p>

<p><em>*</em>*checkPositionRow
public static boolean checkPositionRow(char[][] a,
                                       int row,
                                       int col,
                                       int l)
    Checks if the specified cell is part of a horizontal consecutive sequence of cell containing the same character. The sequence of cells needs to be of length l.</p>

<p>Parameters:</p>

<ul>
<li><p><code>a</code> - a 2-dimensional rectangular array of type char.</p></li>
<li><p><code>row</code> - the row the cell in question</p></li>
<li><p><code>col</code> - the column the cell in question</p></li>
<li><p><code>l</code> - the required length of the sequence
Returns:
true - if the cell is part of a horizontal sequence of length at least l; false - otherwise.<em>*</em>*</p></li>
</ul>

<p>Can't get this game to work, need game to return true if they're 5 or more in a row. Here's my attempt (which doesn't work, just returns true all the time, but i need it to return false when the sequence is less than 5):</p>

<pre><code>public static boolean checkPositionRow(char[][] a, int row, int col, int l){
  int counter = 1;

  for (int i=0; i&lt;a.length; i++) {
    if(a[row][i] == a[row][i+1]) {
      counter++;

      if(counter &gt;= 5){
        return true;
      }                  
    }
  }

  return false;
}
</code></pre>

<p>What am I doing wrong? Help!</p>
