Browse Source

Added GetCell Function to Map

remotes/origin/menu
fdai7012 12 months ago
committed by Julian
parent
commit
5fe25f68e5
  1. 4
      src/main/java/pacmanGame/Map.java
  2. 22
      src/test/java/pacmanTests/MapTest.java

4
src/main/java/pacmanGame/Map.java

@ -75,4 +75,8 @@ public class Map {
} }
} }
} }
public Cell GetCell(Vector2 pos) {
return cells[pos.x][pos.y];
}
} }

22
src/test/java/pacmanTests/MapTest.java

@ -32,4 +32,26 @@ class MapTest {
assertThat(expectedMiddle).isEqualTo(middle); assertThat(expectedMiddle).isEqualTo(middle);
assertThat(expectedBottomRight).isEqualTo(bottomRight); assertThat(expectedBottomRight).isEqualTo(bottomRight);
} }
@Test
void Map_getCell_returnsCorrectCells() {
// arrange
String[] mapTest = {
"wew",
"w..",
"ee."
};
Map testMap = new Map(mapTest);
Cell expectedTopLeft = testMap.cells[0][0];
Cell expectedMiddle = testMap.cells[1][1];
Cell expectedBottomRight = testMap.cells[2][2];
// act
Cell topLeft = testMap.GetCell(new Vector2(0, 0));
Cell middle = testMap.GetCell(new Vector2(1, 1));
Cell bottomRight = testMap.GetCell(new Vector2(2, 2));
// assert
assertThat(expectedTopLeft).isEqualTo(topLeft);
assertThat(expectedMiddle).isEqualTo(middle);
assertThat(expectedBottomRight).isEqualTo(bottomRight);
}
} }
Loading…
Cancel
Save