title: Need help implementing en passant Pawn capture and promotion
body: <p>I am working on a chessgame and have been able to make my Pawn piece move both one and two squares forward and preventing it from moving two squares forward after its first move. In addition, the Pawn Piece is able to capture piece diagonally but doesn't perform enpassant capture and pawn promotion. For pawn promotion, i need an idea on how to swap the pawn piece with another piece when its targetRow == 0 or 7. Please i will be grateful if someone can help me with a logic or idea on how to implement these two features.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    private boolean isValidPawnMove(int sourceRow, int sourceColumn, int targetRow, int   
      targetColumn){
  
      boolean isValid = false;
  
      if(isTargetLocationFree()){
  
          if(sourceColumn == targetColumn){
              //same column
              if(sourcePiece.getColor() == Piece.YELLOW_COLOR){
                  //yellow
                  if(sourceRow + 1 == targetRow ){
                      //move one up
                      isValid = true;
  
                  }else if(sourceRow == 1 &amp;&amp; targetRow == 3){
                      if(sourceRow + 2 == targetRow) {
                      isValid = true;
                      }                   
                  }else{
                      //not moving one up
                      isValid = false;
                  }
  
              }else{
                  //brown
                  if(sourceRow - 1 == targetRow){
                      //move one down
                      isValid = true;
  
                  }else if(sourceRow == 6 &amp;&amp; targetRow == 4){
                      if(sourceRow - 2 == targetRow) {
                         isValid = true;
                      }
                  }else{
                      //not moving one down
                      isValid = false;
                  }                   
              }
          }else{
              //not the same column
              isValid = false;
          }
      }else if(isTargetLocationCaptureable()){
  
          if(sourceColumn + 1 == targetColumn || sourceColumn - 1 == targetColumn ){
              //one column to the right or left
              if(sourcePiece.getColor() == Piece.YELLOW_COLOR){
                  //yellow
                  if(sourceRow + 1 == targetRow){
                      //move one up
                      isValid = true;
                  }else{
  
                      //not moving one up
                      isValid = false;
                  }
              }else{
                  //brown
                  if(sourceRow - 1 == targetRow ){
                      //move one down
                      isValid = true;
                  }else{
                      //not moving one down                       
                      isValid = false;
                  }
              }
          }else{
              //One column to the left or right
              isValid = false;
          }   
      }
  
          return isValid;
  }
  
  private boolean isTargetLocationCaptureable(){
  if(targetPiece == null){
      return false;
  }else if( targetPiece.getColor() != sourcePiece.getColor()){
      return true;
  }else{
      return false;
  }
  }
  
  private boolean isTargetLocationFree(){
  return targetPiece == null;
  }
  </code></pre>