Browse Source

figure movement test: white rook valid down

feat-figureMovement
JD 4 years ago
parent
commit
2ee4adc807
  1. 7
      fh.fd.ci.client/src/main/java/de/fd/fh/Figure.java
  2. 5
      fh.fd.ci.client/src/main/java/de/fd/fh/FigureFarmer.java
  3. 7
      fh.fd.ci.client/src/test/java/de/fd/fh/FigureTest.java

7
fh.fd.ci.client/src/main/java/de/fd/fh/Figure.java

@ -16,13 +16,6 @@ public class Figure
return false; return false;
} }
int stepSize = src / fieldLength - dst / fieldLength; // hoch/runter
if (stepSize <= 0) // weißer Bauer kein Schritt "runter"
{
return false;
}
return true; return true;
} }
} }

5
fh.fd.ci.client/src/main/java/de/fd/fh/FigureFarmer.java

@ -12,6 +12,11 @@ public class FigureFarmer extends Figure
return false; return false;
} }
if (stepSize <= 0) // weißer Bauer kein Schritt "runter"
{
return false;
}
return super.moveAllowed(src, dst, field); return super.moveAllowed(src, dst, field);
} }
} }

7
fh.fd.ci.client/src/test/java/de/fd/fh/FigureTest.java

@ -77,4 +77,11 @@ class FigureTest
Figure f = new Figure(); Figure f = new Figure();
assertTrue(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 0 + 4, new int[Figure.fieldLength * Figure.fieldLength])); assertTrue(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 0 + 4, new int[Figure.fieldLength * Figure.fieldLength]));
} }
@Test
void whiteRookValidMoveDown()
{
Figure f = new Figure();
assertTrue(f.moveAllowed(Figure.fieldLength * 4 + 4, Figure.fieldLength * 7 + 4, new int[Figure.fieldLength * Figure.fieldLength]));
}
} }
Loading…
Cancel
Save