diff --git a/fh.fd.ci.client/src/main/java/de/fd/fh/FigureBishop.java b/fh.fd.ci.client/src/main/java/de/fd/fh/FigureBishop.java new file mode 100644 index 0000000..80ea718 --- /dev/null +++ b/fh.fd.ci.client/src/main/java/de/fd/fh/FigureBishop.java @@ -0,0 +1,15 @@ +package de.fd.fh; + +public class FigureBishop extends Figure +{ + @Override + public boolean moveAllowed(int src, int dst, Figure[] field) + { + if ((dst-src) % 8 == 0) // nach oben/unten nicht erlaubt + { + return false; + } + + return super.moveAllowed(src, dst, field); + } +} diff --git a/fh.fd.ci.client/src/test/java/de/fd/fh/FigureBishopTest.java b/fh.fd.ci.client/src/test/java/de/fd/fh/FigureBishopTest.java new file mode 100644 index 0000000..3dc528a --- /dev/null +++ b/fh.fd.ci.client/src/test/java/de/fd/fh/FigureBishopTest.java @@ -0,0 +1,16 @@ +package de.fd.fh; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class FigureBishopTest +{ + @Test + void checkInvalidMovesBishop() + { + Figure f = new FigureBishop(); + + assertFalse(f.moveAllowed(45, 37, new Figure[64])); + } +} \ No newline at end of file