From 036c0dccdd5b14773da07a10e44d06426dd7b1b5 Mon Sep 17 00:00:00 2001 From: Felix Krull Date: Tue, 11 Jan 2022 10:15:06 +0100 Subject: [PATCH] Add FieldTypes to Gameboard --- src/main/java/Gameboard.java | 16 +++++++++++++++- src/test/java/GameboardTest.java | 27 +++++++++++++++++++++++++-- 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/main/java/Gameboard.java b/src/main/java/Gameboard.java index 8ffdcd0..c4c6212 100644 --- a/src/main/java/Gameboard.java +++ b/src/main/java/Gameboard.java @@ -2,7 +2,21 @@ public class Gameboard { int[] board; public Gameboard() { - board = new int[11]; + board = new int[56]; + } + + public void initGameboard (){ + board[0] = 1; + board[10] = 1; + board[20] = 1; + board[30] = 1; + board[9] = 2; + board[19] = 2; + board[29] = 2; + board[39] = 2; + for (int i = 40; i < board.length; i++) { + board[i] = 3; + } } } diff --git a/src/test/java/GameboardTest.java b/src/test/java/GameboardTest.java index 052c9b4..df0d89c 100644 --- a/src/test/java/GameboardTest.java +++ b/src/test/java/GameboardTest.java @@ -19,7 +19,7 @@ public class GameboardTest { @Test void checkGameboardSize() { - String expectedResult = "11"; + String expectedResult = "56"; String currentResult = "" + gb.board.length; assertThat(currentResult).describedAs("Dimensions").isEqualTo(expectedResult); @@ -27,7 +27,7 @@ public class GameboardTest { @Test void checkGameboardFilled() { - int[] expectedGameboard = new int[11]; + int[] expectedGameboard = new int[56]; for(int i = 0; i < expectedGameboard.length; i++) { expectedGameboard[i] = 0; } @@ -36,5 +36,28 @@ public class GameboardTest { assertThat(givenGameboard).describedAs("Initial Gameboard").isEqualTo(expectedGameboard); } + @ParameterizedTest + @MethodSource("FieldStream") + void checkGameboardFieldType(String testname, int Pos, int expectedResult) { + gb.initGameboard(); + int currentType = gb.board[Pos]; + assertThat(currentType).describedAs("Field Type").isEqualTo(expectedResult); + } + + static Stream FieldStream () { + return Stream.of( + Arguments.of("Normal Path", 1, 0), + Arguments.of("Starting Field", 0, 1), + Arguments.of("Starting Field", 10, 1), + Arguments.of("Starting Field", 20, 1), + Arguments.of("Starting Field", 30, 1), + Arguments.of("Doorway Field", 9, 2), + Arguments.of("Doorway Field", 19, 2), + Arguments.of("Doorway Field", 29, 2), + Arguments.of("Doorway Field", 39, 2), + Arguments.of("House Field", 40, 3), + Arguments.of("House Field", 55, 3) + ); + } }