Browse Source

Merge branch 'develop' into Player

AIPlayer
Jonas Wagner 3 years ago
parent
commit
08b45434a1
  1. 9
      src/main/java/Figure.java
  2. 17
      src/main/java/Game.java
  3. 8
      src/main/java/Player.java
  4. 16
      src/test/java/GameTest.java
  5. 13
      src/test/java/PlayerTest.java

9
src/main/java/Figure.java

@ -0,0 +1,9 @@
public class Figure {
int position;
public Figure() {
this.position = -1;
}
}

17
src/main/java/Game.java

@ -1,7 +1,22 @@
public class Game { public class Game {
Gameboard gb;
Player p1;
Player p2;
Player p3;
Player p4;
public static void main(String[] args) { public static void main(String[] args) {
Gameboard gb = new Gameboard();
Game g = new Game();
g.startGame();
}
public void startGame() {
this.gb = new Gameboard();
gb.initGameboard(); gb.initGameboard();
p1 = new Player("Rot");
p2 = new Player("Blau");
p3 = new Player("Gelb");
p4 = new Player("Grün");
} }
} }

8
src/main/java/Player.java

@ -1,9 +1,17 @@
import javax.sound.midi.Soundbank;
import java.util.Arrays;
public class Player { public class Player {
String name; String name;
Figure[] figures;
public Player (String name) { public Player (String name) {
this.name = name; this.name = name;
figures = new Figure[4];
for(int i = 0; i < 4; i++) {
this.figures[i] = new Figure();
}
} }
@Override @Override

16
src/test/java/GameTest.java

@ -8,4 +8,20 @@ import org.junit.jupiter.params.provider.MethodSource;
public class GameTest { public class GameTest {
private Gameboard gb;
private Player p1;
private Player p2;
private Player p3;
private Player p4;
@BeforeEach
void setup() {
this.gb = new Gameboard();
gb.initGameboard();
p1 = new Player("Rot");
p2 = new Player("Blau");
p3 = new Player("Gelb");
p4 = new Player("Grün");
}
} }

13
src/test/java/PlayerTest.java

@ -29,5 +29,18 @@ public class PlayerTest {
assertThat(calculatedResult).describedAs("Player Name").isEqualTo(expectedResult); assertThat(calculatedResult).describedAs("Player Name").isEqualTo(expectedResult);
} }
@Test
void checkStartPositionOfFigures() {
int expectedResult = -1;
int calculatedResult = p.figures[0].position;
for(int i = 0; i < 4; i++) {
calculatedResult = p.figures[i].position;
if(expectedResult != calculatedResult) {
calculatedResult = 1;
break;
}
}
assertThat(calculatedResult).describedAs("Starting postion of Figures").isEqualTo(expectedResult);
}
} }
Loading…
Cancel
Save