Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an object called ChessBoard. The object should have 2 variables of type i

ID: 3559504 • Letter: C

Question

Create an object called ChessBoard. The object should have 2 variables of type int, count and movecount. Count keeps track of how many chessboard object have been created. Movecount keeps track of how many moves were made on this board so for. You must determine if there variable are static or instance. The object should also have variable which is a double array of type ChessPiece. ChessPiece is another object that YOU ARE NOT TO CREAT and do not have to know anything about in order to make your ChessBoard object. Keep in mind, that a chessboard is an 8*8 grid. Create a constructor that does not take in any parameters. In the constructor something should be done with the 2 int variables. The only other line of code in the constructor is a call to the instance method setup(), which will set up the piece in their starting positions. DO NOT create method setup.

Explanation / Answer

public class ChessBoard{
static int count = 0; //keeps track of how many chessboard object have been created
private int movecount; //keeps track of how many moves were made on this board so for
private ChessPiece[][] chessPiece;
public ChessBoard(){
movecount = 0; //Initialise movecount to 0 for each ChessBoard object
count = count + 1; //Increase count everytime a new ChessBoard object is created
chessPiece = new ChessPiece[8][8]; //Initialise to 8x8 array
setup();
}
public void setup(){
}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote