title: Console-based Connect Four game - diagonal win checker algorithm
body: <p>I'm more or less new to Java.</p>
  
  <p>I'm making a console-based connect 4 game in java and I'm pretty much done, I'm just struggling with how to check for a diagonal win (four pieces in a row diagonally). My vertical/horizontal win checkers are working fine, but I can't figure out how to do a similar thing for a diagonal-checker. The board is a 2d-array which is printed to the console, and to check for a win, I check for four of the same piece next to each other or above each other.</p>
  
  <p>Here are the bits of board code:</p>
  
  <pre><code>private String board[][] = new String[8][8];
  </code></pre>
  
  <p>creates array</p>
  
  <pre><code>    for (int i = 0; i &lt; 8; i++) {
          for (int j = 0; j &lt; 8; j++) {
              board[i][j] = "( )";
          }
      }
  </code></pre>
  
  <p>fills the board with blank slots</p>
  
  <pre><code>void displayBoard() {
      for (int i = 1; i &lt; 9; i++) {
          System.out.print(" " + i + " ");
      }
      System.out.println();
      for (int i = 0; i &lt; 8; i++) {
          for (int j = 0; j &lt; 8; j++) {
              System.out.print(board[i][j]);
          }
          System.out.println();
      }
  }
  </code></pre>
  
  <p>And here is the winchecker</p>
  
  <pre><code>boolean winCheck1() {
      String p = "(" + piece1 + ")";
      for (int i = 0; i &lt; 8; i++) {
          for (int j = 0; j &lt; 5; j++) {
              if ((board[i][j].equals(p) &amp;&amp; board[i][j + 1].equals(p)
                      &amp;&amp; board[i][j + 2].equals(p) &amp;&amp; board[i][j + 3]
                      .equals(p))) {
                  this.win1();
                  return false;
              }
          }
      }
      for (int i = 0; i &lt; 8; i++) {
          for (int j = 0; j &lt; 5; j++) {
              if ((board[j][i].equals(p) &amp;&amp; board[j + 1][i].equals(p)
                      &amp;&amp; board[j + 2][i].equals(p) &amp;&amp; board[j + 3][i]
                      .equals(p))) {
                  this.win1();
                  return false;
              }
          }
      }
      this.play2();
      return false;
  }
  </code></pre>
  
  <p>Any help would be appreciated. Thanks!</p>