Question: Java Main task: given a chess piece and its initial position (x, y), verify that you can move it to the new position. The program

Java Main task: given a chess piece and its initial position (x, y),

Main task: given a chess piece and its initial position (x, y), verify that you can move it to the new position. The program should write "Piece_Name at X, Y can move to X+1, Y" or "Piece_Name at X, Y can NOT move to X+1, Y". For example, "Queen at D, 1 can move to E, 1. When verifying the move, check that initial and final positions are inside the chess board, new position is possible based on the rules for that piece and consider that the chess board only has that piece. You are given a text file with several chess pieces. Number of pieces, types of pieces, and the order of the pieces may change every time you read a file. Each row in the file includes piece_name, color, pos X, and pos_Y. You must write a program to verify the movement of each chess piece in the given file. You must read values from the file, create an object/structure for each piece, allocate all the pieces in an array, prompt the user for the new position, and transverse the array verifying a move for each piece with the new position. You should print the verification result for each piece. Chess additional information. A chess board contains 8 by 8 boxes which are potential places for the chess pieces. There are six different pieces: Pawn, Rook, Knight, Bishop, Queen, and King. Each piece has its own movement rules. Your task is to read some movements from a file and validate those ones.

Step by Step Solution

3.55 Rating (165 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import javaioFile import javaioFileNotFoundException import javautilArrayList import javautilList import javautilScanner class ChessPiece private Stri... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!