Example #1
0
        public Tool[,] makeTools()
        {
            Tool[,] bord;
            bord = new Tool[8, 8];
            for (int z = 0; z < 8; z++)
            {
                for (int i = 0; i < 8; i++)
                {
                    if (z < 2)
                    {
                        bord[z, i] = new Pawn(1);
                    }
                    if (z < 6 && z > 1)
                    {
                        bord[z, i] = new Space(0);
                    }
                    if (z > 5)
                    {
                        bord[z, i] = new Pawn(2);
                    }
                }
            }
            bord[0, 2] = new Bishop(1);
            bord[0, 5] = new Bishop(1);
            bord[7, 2] = new Bishop(2);
            bord[7, 5] = new Bishop(2);
            bord[0, 1] = new Knight(1);
            bord[0, 6] = new Knight(1);
            bord[7, 1] = new Knight(2);
            bord[7, 6] = new Knight(2);
            bord[0, 7] = new Rook(1);//
            bord[7, 7] = new Rook(2);
            bord[7, 0] = new Rook(2);
            bord[0, 3] = new Qween(1);;
            bord[7, 3] = new Qween(2);
            bord[0, 4] = new King(1);
            bord[7, 4] = new King(2);

            return(bord);
        }
Example #2
0
        static void Main(string[] args)
        {
            string figName = Console.ReadLine();
            int    x1      = Convert.ToInt32(Console.ReadLine());
            int    y1      = Convert.ToInt32(Console.ReadLine());
            int    x2      = Convert.ToInt32(Console.ReadLine());
            int    y2      = Convert.ToInt32(Console.ReadLine());

            bool   isValid = false;
            Figure figure;

            switch (figName)
            {
            case "N":
                figure = new Knight(x1, y1);
                break;

            case "Q":
                figure = new Queen(x1, y1);
                break;

            case "B":
                figure = new Bishop(x1, y1);
                break;

            case "K":
                figure = new King(x1, y1);
                break;

            case "R":
                figure = new Rook(x1, y1);
                break;

            default:
                return;
            }
            isValid = figure.Move(x2, y2);
            Console.WriteLine(isValid ? "YES" : "NO");
        }