Answered step by step
Verified Expert Solution
Question
1 Approved Answer
IN JAVA COMPLETE THE PROGRAM You are going to write a program that checks chess moves for legality and display possible moves a chess piece
IN JAVA COMPLETE THE PROGRAM
You are going to write a program that checks chess moves for legality and display possible moves a chess piece might make. You will start by writing an abstract parent for all of our different chess pieces called
ChessPiece. Then you will write Knight, WhitePawn, Rook, Bishop, and Queen classes. I have
provided a King class as an example and a BlackPiece class which is used as a dummy class for
all black pieces We will only test with white pieces. I have also provided a Board class and a
ChessMoveChecker program class for you.
The abstract ChessPiece Class
This class must have exactly the following protected instance variables attributesfields:
rowNum: an integer specifying the row of the board the piece is on
columnNum: an integer specifying the column of the board the piece is on
pieceColor: an integer specifying the color of the piece using a constant from Board
This class must have at least the following public methods. You may wish to add additional
protected methods that have logic needed by multiple subclasses:
A constructor that takes in values for all three instance variables.
A move method that takes the new row and column as parameters and updates the
pieces location instance variables.
A getColor method that returns pieceColor.
An abstract getLabel method that returns a character and takes no parameters.
An abstract isLegalMove method that returns a boolean and takes three parameters: an
integer destRow representing the destination row, an integer destCol representing the
destination column, and a Board object theBoard, which is the chess board were using.
An abstract generateLegalMoves void method that takes two parameters: a D array of
characters boardData that we will use for showing where the piece can move and a
Board object theBoard.
You will then create the following subclasses of ChessPiece. I highly recommend doing them in
this order.
Knight
Rook
WhitePawn because pawns move in only one direction, the different colors behave
differently, unlike other pieces
Bishop
Queen
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started