package aula;

/**
 * Represents a queen in a chess board.
 *
 * @version 0.01  06 Apr 2000
 * @author Carlos Figueira Filho (csff@cin.ufpe.br)
 */
public class Rainha {

  /**
   * The linha of the board (1-8).
   */
  private int linha;

  /**
   * The Coluna of the board (1-8).
   */
  private int Coluna;

  /**
   * Class constructor.
   *
   * @param linha the linha of the board.
   * @param Coluna the Coluna of the board.
   */
  public Rainha(int linha, int Coluna) {
    this.linha = linha;
    this.Coluna = Coluna;
  }

  /**
   * Returns the linha of this queen.
   *
   * @return the linha of this queen.
   */
  public int getLinha() {
    return linha;
  }

  /**
   * Returns the Coluna of this queen.
   *
   * @return the Coluna of this queen.
   */
  public int getColuna() {
    return Coluna;
  }

  /**
   * Checks whether this queen can be attacked by the given one.
   *
   * @param the queen that tries to attack this one
   * @return true if this queen can be attacked by the
   *          given one; false otherwise.
   */
  public boolean ataca(Rainha q) {
    if (q.getLinha() == this.linha || q.getColuna() == this.Coluna)
      return true;
    int x = Math.abs(this.linha - q.getLinha());
    int y = Math.abs(this.Coluna - q.getColuna());
    return (x == y);
  }

}
