Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Passed testTablebaseToStringOutput

  • Loading branch information...
commit 30bc584f44c27c8ff8aca70c16b199e32c366ea7 1 parent af3c240
Kestutis-Z authored
View
22 endgame-oracle/src/main/java/tablebases/Tablebase.java
@@ -123,4 +123,26 @@ protected static int getConsequtiveDuplicateCharsInArrayUpToIndex(
blackPieces = convertCharsToPieces(blackPiecesAsChars, PieceColour.BLACK);
return blackPieces;
}
+
+ @Override
+ public String toString() {
+ List<Piece> whitePieces = getWhitePieces();
+ List<Piece> blackPieces = getBlackPieces();
+
+ String output = "";
+ output += whitePieces.get(0).getPieceType().name();
+ for (int i = 1; i < whitePieces.size(); i++) {
+ output += " + ";
+ output += whitePieces.get(i).getPieceType().name();
+ }
+ output += " vs. ";
+ output += blackPieces.get(0).getPieceType().name();
+ for (int i = 1; i < blackPieces.size(); i++) {
+ output += " + ";
+ output += blackPieces.get(i).getPieceType().name();
+ }
+
+ return output;
+ }
+
}
View
9 endgame-oracle/src/test/java/tablebases/TablebaseTest.java
@@ -99,4 +99,13 @@ public void testGetConsequtiveDuplicateCharsInArrayUpToIndex() {
assertArrayEquals(expectedDuplicates, actualDuplicates);
}
+ @Test
+ public void testTablebaseToStringOutput() {
+ Tablebase tablebase = Tablebase.KPK;
+ String actualString = tablebase.toString();
+ String expectedString = "KING + PAWN vs. KING";
+
+ assertEquals(expectedString, actualString);
+ }
+
}
View
BIN  endgame-oracle/target/classes/tablebases/Tablebase.class
Binary file not shown
View
BIN  endgame-oracle/target/test-classes/tablebases/TablebaseTest.class
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.