Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

What are the characteristics of a virtual path?

Answered: 1 week ago