Can someone help me with my Java program?
This is the method for my MineSweeper game.
And my one JUnit test doesn't pass.
org.opentest4j.AssertionFailedError: array contents differ at index [0][2], expected: <9> but was: <-2>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertArrayEquals.failArraysNotEqual(AssertArrayEquals.java:440)
at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:241)
at org.junit.jupiter.api.AssertArrayEquals.assertArrayElementsEqual(AssertArrayEquals.java:364)
at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:346)
at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:159)
at org.junit.jupiter.api.AssertArrayEquals.assertArrayEquals(AssertArrayEquals.java:155)
at org.junit.jupiter.api.Assertions.assertArrayEquals(Assertions.java:1456)
at MinesweeperTest.testGameTurn(MinesweeperTest.java:113)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
Does anyone have any idea what I'm doing wrong?
Greeting
If you want to have all neighboring fields in the longest line, you need to be on i!=row R & D j!=col test, you only catch the diagonally offset. Whether that’s the mistake, I don’t know.
thank you for the answer.
This is unfortunately not the error :/
Why do you cover the mines at the bottom of the loop in the adjacent fields? If there is a mine, it should be hidden, right?
Yes, thank you.