Skip to content
Browse files

Passed testGetChessPositionDiagram

  • Loading branch information...
1 parent 1c310f8 commit 31ff0a65b8baf4ea9f3eae3f9e1e0ae825024949 Kestutis-Z committed Nov 7, 2012
View
6 endgame-oracle/src/main/java/chess/ChessPositionDiagram.java
@@ -83,9 +83,11 @@ private void verifyMiddleThird(int rank, String middleThird)
throw new IncorrectChessDiagramDrawingException("Incorrect rank in middle third: was " +
"expected " + rank + " but obtained" + (middleThird.charAt(2) - '0'));
for (int file = 1; file <= 8; file++) {
- String pieceAbbreviation = middleThird.substring(7*(file - 1) + 6, 7*(file - 1) + 9);
+ String pieceAbbreviation = Character.isDigit(middleThird.charAt(7 * (file - 1) + 8))
+ ? middleThird.substring(7 * (file - 1) + 6, 7 * (file - 1) + 9)
+ : middleThird.substring(7 * (file - 1) + 6, 7 * (file - 1) + 8);
if (!(Piece.allAbbreviationsOfPieces().contains(pieceAbbreviation)
- && !pieceAbbreviation.equals(" ")))
+ || pieceAbbreviation.equals(" ")))
throw new IncorrectChessDiagramDrawingException("Incorrect piece " +
"abbreviation in file " + file + ", rank " +
rank + ": " + pieceAbbreviation);
View
6 endgame-oracle/src/test/java/chess/ChessPositionDiagramTest.java
@@ -18,7 +18,7 @@ public void testGetChessPositionDiagram() throws IncorrectChessDiagramDrawingExc
" 7| | | | | | | | | \n" +
" |______|______|______|______|______|______|______|______| \n" +
" | | | | | | | | | \n" +
- " 6| | | | | | | | | \n" +
+ " 6| | | | WP | | | WP2 | | \n" +
" |______|______|______|______|______|______|______|______| \n" +
" | | | | | | | | | \n" +
" 5| | | | | | | | | \n" +
@@ -27,10 +27,10 @@ public void testGetChessPositionDiagram() throws IncorrectChessDiagramDrawingExc
" 4| | | | | | | | | \n" +
" |______|______|______|______|______|______|______|______| \n" +
" | | | | | | | | | \n" +
- " 3| | | | | | | | | \n" +
+ " 3| | | | | BR | | | | \n" +
" |______|______|______|______|______|______|______|______| \n" +
" | | | | | | | | | \n" +
- " 2| | | | | | | | | \n" +
+ " 2| | BN | | | | | BK | | \n" +
" |______|______|______|______|______|______|______|______| \n" +
" | | | | | | | | | \n" +
" 1| | | | | | | | | \n" +
View
BIN endgame-oracle/target/classes/chess/ChessPositionDiagram.class
Binary file not shown.
View
BIN endgame-oracle/target/test-classes/chess/ChessPositionDiagramTest.class
Binary file not shown.

0 comments on commit 31ff0a6

Please sign in to comment.
Something went wrong with that request. Please try again.