Browse Source

initial figure placement on field

feat-figureMovement
JD 4 years ago
parent
commit
a9337af708
  1. 12
      fh.fd.ci.client/src/main/java/de/fd/fh/Game.java
  2. 20
      fh.fd.ci.client/src/test/java/de/fd/fh/GameTest.java

12
fh.fd.ci.client/src/main/java/de/fd/fh/Game.java

@ -7,5 +7,17 @@ public class Game
public void initNewGame()
{
mField = new Figure[Figure.fieldLength * Figure.fieldLength];
// Figuren platzieren
for (int i = 0; i < 8; i++) // row
{
if (i == 0 || i == 1 || i == 6 || i == 7)
{
for (int j = 0; j < 8; j++) // col
{
mField[i * 8 + j] = new Figure();
}
}
}
}
}

20
fh.fd.ci.client/src/test/java/de/fd/fh/GameTest.java

@ -15,4 +15,24 @@ class GameTest
assertEquals(Figure.fieldLength * Figure.fieldLength, g.mField.length);
}
// prüft, ob Figuren nach Initialisierung nur an vorgesehenden Positionen stehen
@Test
void newGameInitializationFigurePositions()
{
Game g = new Game();
g.initNewGame();
for (int i = 0; i < 8; i++) // row
{
if (i == 0 || i == 1 || i == 6 || i == 7)
{
for (int j = 0; j < 8; j++) // col
{
assertNotEquals(null, g.mField[i * 8 + j]);
}
}
}
assertEquals(Figure.fieldLength * Figure.fieldLength, g.mField.length);
}
}
Loading…
Cancel
Save