static void Main(string[] args) { Console.WriteLine("Введите код фигуры: K Q R B N"); string pieceCode = Console.ReadLine(); int x1 = int.Parse(Console.ReadLine()); int y1 = int.Parse(Console.ReadLine()); int x2 = int.Parse(Console.ReadLine()); int y2 = int.Parse(Console.ReadLine()); Piece piece; bool isRightMove; switch (pieceCode) { case "K": piece = new King(x1, y1); break; case "Q": piece = new Queen(x1, y1); break; case "R": piece = new Rook(x1, y1); break; case "B": piece = new Bishop(x1, y1); break; case "N": piece = new Knight(x1, y1); break; default: throw new Exception("Invalid piece code"); } isRightMove = piece.Move(x2, y2); Console.WriteLine(isRightMove ? "YES" : "NO"); }
static void Main() { string chess = Console.ReadLine(); Figure test; bool isRightMove = false; switch (chess) { case "K": test = new King(1, 1); isRightMove = test.IsRightMove(2, 1); break; case "Q": test = new Queen(1, 1); isRightMove = test.IsRightMove(2, 1); break; case "B": test = new Bishop(1, 1); isRightMove = test.IsRightMove(2, 1); break; case "N": test = new Knight(1, 1); isRightMove = test.IsRightMove(2, 1); break; case "R": test = new Rook(1, 1); isRightMove = test.IsRightMove(2, 1); break; default: Console.WriteLine("Unknown piece code. Try again."); break; } Console.WriteLine(isRightMove ? "YES" : "NO"); }