Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Students also viewed these Databases questions