mirror of
https://github.com/inf112-v20/Fiasko.git
synced 2025-01-31 23:29:36 +01:00
Merge branch 'master' of https://github.com/inf112-v20/Fiasko
Conflicts: src/test/java/inf112/fiasko/roborally/PositionTest.java
This commit is contained in:
commit
3293734f1f
@ -0,0 +1,37 @@
|
||||
package inf112.fiasko.roborally.element_properties;
|
||||
|
||||
/**
|
||||
* This Interface describes a grid
|
||||
* @param <K> type of element
|
||||
*/
|
||||
public interface IGrid<K> {
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
36
src/test/java/inf112/fiasko/roborally/TestWall.java
Normal file
36
src/test/java/inf112/fiasko/roborally/TestWall.java
Normal file
@ -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());
|
||||
}
|
||||
|
||||
}
|
41
src/test/java/inf112/fiasko/roborally/TileTest.java
Normal file
41
src/test/java/inf112/fiasko/roborally/TileTest.java
Normal file
@ -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());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user