Permalink
Browse files

Extract method getDiagramSquareContent

  • Loading branch information...
1 parent 31ff0a6 commit fe8ed35d38d9383b41c2cd25b9faaef0c32ea963 Kestutis-Z committed Nov 7, 2012
@@ -83,9 +83,7 @@ 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 = 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);
+ String pieceAbbreviation = getDiagramSquareContent(middleThird, file);
if (!(Piece.allAbbreviationsOfPieces().contains(pieceAbbreviation)
|| pieceAbbreviation.equals(" ")))
throw new IncorrectChessDiagramDrawingException("Incorrect piece " +
@@ -94,6 +92,13 @@ private void verifyMiddleThird(int rank, String middleThird)
}
}
+ private String getDiagramSquareContent(String middleThird, int file) {
+ 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);
+ return pieceAbbreviation;
+ }
+
private void verifyDiagramBottom(String lastLine) throws IncorrectChessDiagramDrawingException {
if (!lastLine.equals(" a b c d e f g h "))
throw new IncorrectChessDiagramDrawingException("Incorrect diagram bottom:\n" + lastLine);
Binary file not shown.

0 comments on commit fe8ed35

Please sign in to comment.