Пример #1
0
 /// <summary>
 /// Method that return color of cell
 /// </summary>
 /// <param name="figure">Chess figure for which need to return color</param>
 /// <returns></returns>
 public string GetCellColor(ChessFigure figure)
 {
     if (figure.ChessBoardPoint.Column - 64 + figure.ChessBoardPoint.Row % 2 == 0)
     {
         return("White");
     }
     else
     {
         return("Black");
     }
 }
Пример #2
0
 /// <summary>
 /// Method shows which line two figures are on
 /// </summary>
 /// <param name="figure1">First figure</param>
 /// <param name="figure2">Second figure</param>
 public void DisplayWhichLineTwoFiguresAreOn(ChessFigure figure1, ChessFigure figure2)
 {
     if (IsTwoFuguresOnOneDiagonal(figure1, figure2))
     {
         Console.WriteLine("On one dioganal");
     }
     else if (IsTwoFuguresOnOneHorizontal(figure1, figure2))
     {
         Console.WriteLine("On one horizontal");
     }
     else if (IsTwoFuguresOnOneVertical(figure1, figure2))
     {
         Console.WriteLine("On one vertical");
     }
     else
     {
         Console.WriteLine("No one");
     }
 }
Пример #3
0
        /// <summary>
        /// Main method
        /// </summary>
        static void Main()
        {
            try
            {
                ChessFigure figure1 = new ChessFigure('a', 1);
                ChessFigure figure2 = new ChessFigure('g', 3);
                ChessBoard  board   = new ChessBoard();

                Console.WriteLine(board.GetCellColor(figure1));
                Console.WriteLine(board.GetCellColor(figure2));
                board.DisplayWhichLineTwoFiguresAreOn(figure1, figure2);
            }
            catch (OutOfRangeChessBoardException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Пример #4
0
 /// <summary>
 /// Method shows whether the figures are on the same diagonal
 /// </summary>
 /// <param name="figure1">First figure</param>
 /// <param name="figure2">Second figure</param>
 /// <returns></returns>
 public bool IsTwoFuguresOnOneDiagonal(ChessFigure figure1, ChessFigure figure2)
 {
     return(Math.Abs(figure1.ChessBoardPoint.Row - figure2.ChessBoardPoint.Row) == Math.Abs(figure1.ChessBoardPoint.Column - figure2.ChessBoardPoint.Column));
 }
Пример #5
0
 /// <summary>
 /// Method shows whether the figures are on the same horizontal
 /// </summary>
 /// <param name="figure1">First figure</param>
 /// <param name="figure2">Second figure</param>
 /// <returns></returns>
 public bool IsTwoFuguresOnOneHorizontal(ChessFigure figure1, ChessFigure figure2)
 {
     return(figure1.ChessBoardPoint.Row == figure2.ChessBoardPoint.Row);
 }
Пример #6
0
 /// <summary>
 /// Method shows whether the figures are on the same vertical
 /// </summary>
 /// <param name="figure1">First figure</param>
 /// <param name="figure2">Second figure</param>
 /// <returns></returns>
 public bool IsTwoFuguresOnOneVertical(ChessFigure figure1, ChessFigure figure2)
 {
     return(figure1.ChessBoardPoint.Column == figure2.ChessBoardPoint.Column);
 }