diff --git a/src/main/java/inf112/fiasko/roborally/element_properties/IGrid.java b/src/main/java/inf112/fiasko/roborally/element_properties/IGrid.java new file mode 100644 index 0000000..29f0a4c --- /dev/null +++ b/src/main/java/inf112/fiasko/roborally/element_properties/IGrid.java @@ -0,0 +1,37 @@ +package inf112.fiasko.roborally.element_properties; + +/** + * This Interface describes a grid + * @param type of element + */ +public interface IGrid { + + /** + * returns the width of the grid + * @return the width + */ + int getWidth(); + + /** + * returns the height of the grid + * @return the height + */ + int getHeight(); + + /** + * returns the element in a given x and y coordinate + * @param x coordinate in the grid + * @param y coordinate in the grid + * @return element in the x and y coordinate + * @throws IllegalArgumentException throws exception if coordinates are not in the grid + */ + K getElement(int x,int y) throws IllegalArgumentException; + + /** + * places the element in the given x and y coordinate + * @param x coordinate + * @param y coordinate + * @param element that is being placed in the grid + */ + void setElement(int x, int y, K element); +} diff --git a/src/main/java/inf112/fiasko/roborally/element_properties/Wall.java b/src/main/java/inf112/fiasko/roborally/element_properties/Wall.java new file mode 100644 index 0000000..fb8c8be --- /dev/null +++ b/src/main/java/inf112/fiasko/roborally/element_properties/Wall.java @@ -0,0 +1,39 @@ +package inf112.fiasko.roborally.element_properties; + +public class Wall { + /** + * This class is a representation of a wall + */ + private WallType wall; + private Direction direction; + + /** + * Initializes the wall + * @param wall gives the type of wall eks. wall normal or wall corner + * @param direction gives the direction the wall is facing. + */ + public Wall (WallType wall,Direction direction){ + this.wall = wall; + this.direction = direction; + } + + /** + * Gets the type of the wall + * @return the wall type + */ + public WallType getWallType() { + return wall; + } + + /** + * Gets the direction of the wall + * @return the direction of the wall + */ + public Direction getDirection(){ + return direction; + } + + + + +} diff --git a/src/test/java/inf112/fiasko/roborally/PositionTest.java b/src/test/java/inf112/fiasko/roborally/PositionTest.java index 4f30582..825e0c5 100644 --- a/src/test/java/inf112/fiasko/roborally/PositionTest.java +++ b/src/test/java/inf112/fiasko/roborally/PositionTest.java @@ -13,11 +13,11 @@ public class PositionTest { testPosition = new Position(3, 4); } @Test - public void getXPosition(){ + public void testGetXPosition(){ assertEquals(3,testPosition.getXCoordinate()); } @Test - public void getYPosition(){ + public void testGetYPosition(){ assertEquals(4,testPosition.getYCoordinate()); } } diff --git a/src/test/java/inf112/fiasko/roborally/TestWall.java b/src/test/java/inf112/fiasko/roborally/TestWall.java new file mode 100644 index 0000000..c94ec6a --- /dev/null +++ b/src/test/java/inf112/fiasko/roborally/TestWall.java @@ -0,0 +1,36 @@ +package inf112.fiasko.roborally; + +import inf112.fiasko.roborally.element_properties.Direction; +import inf112.fiasko.roborally.element_properties.Wall; +import inf112.fiasko.roborally.element_properties.WallType; +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +public class TestWall { + @Test + public void testWallGetWallTypeNormal(){ + Wall testGetWall = new Wall(WallType.WALL_NORMAL, Direction.NORTH); + assertEquals(WallType.WALL_NORMAL, testGetWall.getWallType()); + } + @Test + public void testWallGetWallTypeCorner(){ + Wall testGetWall = new Wall(WallType.WALL_CORNER, Direction.NORTH); + assertEquals(WallType.WALL_CORNER, testGetWall.getWallType()); + } + @Test + public void testWallGetWallTypeLaserSingle(){ + Wall testGetWall = new Wall(WallType.WALL_LASER_SINGLE, Direction.NORTH); + assertEquals(WallType.WALL_LASER_SINGLE, testGetWall.getWallType()); + } + @Test + public void testWallGetDirectionNorth(){ + Wall testGetWall = new Wall(WallType.WALL_CORNER, Direction.NORTH); + assertEquals(Direction.NORTH, testGetWall.getDirection()); + } + @Test + public void testWallGetDirectionEast(){ + Wall testGetWall = new Wall(WallType.WALL_CORNER, Direction.EAST); + assertEquals(Direction.EAST, testGetWall.getDirection()); + } + +} diff --git a/src/test/java/inf112/fiasko/roborally/TileTest.java b/src/test/java/inf112/fiasko/roborally/TileTest.java new file mode 100644 index 0000000..7ef796b --- /dev/null +++ b/src/test/java/inf112/fiasko/roborally/TileTest.java @@ -0,0 +1,41 @@ +package inf112.fiasko.roborally; + +import inf112.fiasko.roborally.element_properties.Direction; +import inf112.fiasko.roborally.element_properties.TileType; +import inf112.fiasko.roborally.objects.Tile; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.*; + +public class TileTest { + private Tile tile; + private Tile tile2; + + @Before + public void setUp() { + tile = new Tile(TileType.HOLE, Direction.NORTH); + tile2 = new Tile(TileType.COGWHEEL_RIGHT, Direction.SOUTH); + } + + @Test + public void getTileTypeFromTile() { + assertEquals(TileType.HOLE, tile.getTileType()); + } + + @Test + public void getTileTypeFromTile2() { + assertEquals(TileType.COGWHEEL_RIGHT, tile2.getTileType()); + } + + + @Test + public void getDirectionFromTile() { + assertEquals(Direction.NORTH, tile.getDirection()); + } + + @Test + public void getDirectionFromTile2() { + assertEquals(Direction.SOUTH, tile2.getDirection()); + } +} \ No newline at end of file