Пример #1
0
        static void Main()
        {
            var board   = new ChessBoard();
            var factory = new PieceFactory(board);

            for (int i = 0; i < ChessBoard.FieldSize; ++i)
            {
                string line = Console.ReadLine();
                for (int j = 0; j < ChessBoard.FieldSize; ++j)
                {
                    if (line == null)
                    {
                        throw new NullReferenceException();
                    }

                    board.Add(factory.NewPiece(j, i, line[j]));
                }
            }
            int status = board.GetStatus();

            switch (status)
            {
            case ChessBoard.Ok:
                Console.WriteLine("ok");
                break;

            case ChessBoard.Check:
                Console.WriteLine("check");
                break;

            case ChessBoard.Mate:
                Console.WriteLine("mate");
                break;

            case ChessBoard.Stalemate:
                Console.WriteLine("stalemate");
                break;

            default:
                throw new Exception("unknown state");
            }
        }