Question
Write a class (and a client class to test it) that encapsulates the numbers of the various chessboard pieces in a chess game. You should
Write a class (and a client class to test it) that encapsulates the numbers of the various chessboard pieces in a chess game. You should have two instance variables:
a two-dimensional array of integers; each array element represents how many of a particular chess piece of a particular color are on the board. In order to set it up, consider the following:
The first dimension represents the color of the pieces. On a chessboard, there are white and black pieces.
The second dimension represents the pieces themselves. On a chessboard, we have on each side: one king, one queen, two bishops, two knights, two rooks, and eight pawns.
a single-dimensional array describing the pieces (king, queen, etc.) Your constructor can simply be a default constructor, declaring and instantiating the two arrays to match the preceding information. You should include the following methods:
a method with a void return value, called player A Takes Player B, updating the array based on a piece being taken by the opponent. It takes two parameters:
a boolean parameter representing whether white takes black or black takes white an int parameter representing which piece gets taken
a method returning how many of a particular piece are on the board (this method takes a parameter representing the piece)
a method taking a boolean as a parameter, representing a color and returning the value of the board for that particular color. You can consider that a king is worth 0 points, a queen is worth 6 points, a rook is worth 4 points, a knight and a bishop are each worth 3 points, and a pawn is worth 1 point
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