title: Creating a Nested for Loop to Scan Chess Board
body: <p>Shown here is the class ChessBoard which creates the Multi-D array pieces- representing a chess board (8x8). When a piece is moving I am trying to scan the board to see if the piece will move through any spaces that are occupied (and throw illegalMove exception if so). Attached below is how I started the nested for loop for each chessPiece. 
  How do I create a nest for-loop to scan the spots[][] for a space's vacancy or not </p>
  
  <pre><code>public class ChessBoard {
  
  private Piece spots[][];
  
  public ChessBoard() {
      spots = new Piece[8][8];    
  }
  
  public void placePieceAt(Piece piece, ChessPosition position) 
  {
      spot[position.getX()][position.getY()] = piece;
      piece.setPosition(position);
  }
  public abstract class Piece {
  
  private ChessPlayer owner;
  private ChessGame game;
  protected ChessPosition position;
  
  
  
  protected CPiece(ChessPlayer owner, ChessGame game, ChessPosition init_position) {
      this.owner = owner;
      this.game = game;
      this.position = null;
  
      game.getBoard().placePieceAt(this, init_position);
  }
  
  ******here is where I was trying 
  public void checkIfPositionOccupied(ChessPosition destination){
      ChessBoard[][] occupiedSpaces = new ChessBoard[8][8];
      for (int i = 0; i &lt;8 ; i++){
          for(int j = 0; j&lt;8; i++){
  
  
          }
      }
  
  }
  public void moveTo(ChessPosition destination) 
  
  
  
          throws IllegalMove
  {
      // Replace with your code as necessary
      throw new IllegalMove(this, position, destination);
  }
  
  public char getMark() {
      return mark;
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>class Rook extends Piece {
  public Rook(ChessPlayer owner, ChessGame game, ChessPosition init_position) {
      super(owner, game, init_position);
      if (owner == game.getPlayer1()) {
          mark = 'r';
      } else {
          mark = 'R';
      }
  }   
  
  public void moveTo(ChessPosition destination) throws IllegalMove
  {
      if((position.getX() == destination.getX() &amp;&amp; position.getY() != destination.getY()) || (position.getX() != destination.getX() &amp;&amp; position.getY() == destination.getY())){
          setPosition(destination);
      } else {
          throw new IllegalMove(this, position, destination);
      }
  }
  </code></pre>
  
  <p>}</p>