Question: J-UNIT Java programming Othello Board Game! I need a J-Unit test case for this bit of code ____ /** * This function is used to

J-UNIT Java programming

Othello Board Game!

I need a J-Unit test case for this bit of code ____

/**

* This function is used to check to see if there are any pieces to capture

* in the selected direction (direction is set by xChange & yChange)

* @param x

* @param y

* @param xChange

* @param yChange

* @return true if the selection direction can capture pieces, else false

*/

public boolean checkDirections(int x, int y, int xChange, int yChange) {

//makes sure the move is on the Board

if (!onBoard(x, y))

return false;

//returns false if there is already a piece in the selected space

if (boardPieces[x][y] != 0)

return false;

x += xChange;

y += yChange;

//makes sure that move is on the board

if (!onBoard(x, y))

return false;

//makes sure that the piece immediately adjacent to it isn't the same player

if (boardPieces[x][y] == currPlyr)

return false;

//goes through the remaining pieces & returns true there are opponents pieces

//surrounded on both sides by the current player's pieces, else it returns false

for (; onBoard(x, y); x += xChange, y += yChange) {

if (boardPieces[x][y] == 0)

return false;

if (boardPieces[x][y] == currPlyr) {

finalX = x;

finalY = y;

return true;

}

}

return false;

}

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 Databases Questions!