Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For the following, how do I write the Junit for them so that the expected result is met using the information in the message? this

For the following, how do I write the Junit for them so that the expected result is met using the information in the message? this is about chess pieces
1. Failed: testPawnKills(ChessPieceGraderTest)
Message: Unexpected canKill result for i=1 j=0 expected: but was:
2. Failed: testPawnMoves(ChessPieceGraderTest)
Message: Piece at :0,0, Unexpected canMove result for i=1 j=0 expected: but was:
some statements are false and others are true. attached is where im faling in my JUnit test and i need to fix it to pass those two errors.
-------------------------------------------------------------
/**
* Test whether a generic chess piece can move to certain spots.
*/
@Test
public void canMoveToTest() {
Piece genericBlackPiece = new Piece(standardBoard, BLACK);
Piece genericWhitePiece = new Piece(standardBoard, WHITE);
genericBlackPiece.moveTo(0,0);
genericWhitePiece.moveTo(2,2);
// A generic piece should be able to move anywhere, except ally spots
assertFalse(genericBlackPiece.canMoveTo(xGenericPieceLocation, yGenericPieceLocation)); // friendly
assertTrue(genericBlackPiece.canMoveTo(1, 1)); // empty
assertFalse(genericBlackPiece.canMoveTo(0, 0)); // same spot
assertTrue(genericBlackPiece.canMoveTo(2,2)); // enemy spot
}
/**
* Test to make sure pawns move properly.
*
* Note: White pawns move up, Black pawns move down.
*/
@Test
public void testPawnMovements(){
Pawn testPawn = new Pawn(standardBoard, WHITE, 3, 3);
//One step
assertTrue(testPawn.canMoveTo(2, 3));
//Two step first move
assertTrue(testPawn.canMoveTo(1, 3));
//Three step
assertFalse(testPawn.canMoveTo(0, 3));
//Back step
assertFalse(testPawn.canMoveTo(4, 3));
// Diagonal without enemies
assertFalse(testPawn.canMoveTo(2, 2));
// Diagonal with enemies
Pawn testPawn2 = new Pawn(standardBoard, BLACK, 2, 2);
assertTrue(testPawn.canMoveTo(2, 2));
// One step, black
assertTrue(testPawn2.canMoveTo(3, 2));
// back step, black
assertFalse(testPawn2.canMoveTo(1, 2));
//Invalid move, out-of-bounds
testPawn.moveTo(0, 0);
assertFalse(testPawn.canMoveTo(-1, 0));
// Invalid move, partner in front
testPawn.moveTo(3, 3);
Pawn testPawn3 = new Pawn(standardBoard, WHITE, 2, 3);
assertFalse(testPawn.canMoveTo(2, 3));
// Two step, already moved
testPawn3.moveTo(5, 5);
assertFalse(testPawn3.canMoveTo(3, 5));
}

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

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

2. Avoid controlling language, should, must, have to.

Answered: 1 week ago