Tobias og Kristian lagde en Position class. og begynnte på testene for classen

This commit is contained in:
Petter Tobias Madsen 2020-02-18 14:39:33 +01:00
parent 8b30c8967f
commit 470b1bcbd8
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,33 @@
package inf112.fiasko.roborally.game;
public class Position {
private int xPosition;
private int yPosition;
/**
* initalises the x and y cooardinats.
* @param xPosition sets the x position.
* @param yPosition sets the y position.
*/
public Position(int xPosition, int yPosition) {
this.xPosition = xPosition;
this.yPosition = yPosition;
}
/**
* gets x coordinate of the position.
* @return the x coordinate of the position.
*/
public int getXCoordinate() {
return xPosition;
}
/**
* gets y coordinate of the position.
* @return the y coordinate of the position.
*/
public int getYCoordinate() {
return yPosition;
}
}

View File

@ -0,0 +1,15 @@
package inf112.fiasko.roborally;
import inf112.fiasko.roborally.game.Position;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class PositionTest {
@Test
public void TestGetXPosition(){
Position testXPosition = new Position(3,4);
assertEquals(3,testXPosition.getXCoordinate());
}
}