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

1 Expert Approved Answer
Step: 1 Unlock 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 Programming Questions!