This commit is contained in:
Kristian Knarvik 2020-02-20 12:52:15 +01:00
commit 2eac95fef9
3 changed files with 64 additions and 1 deletions

View File

@ -0,0 +1,41 @@
package inf112.fiasko.roborally.element_properties;
/**
* this class represtents a robot
*/
public class Robot {
private int robotDamageTaken = 0;
private int playerId; //might not be needed
private boolean inPowerDown = false;
private int lastFlagVisited = 0;
private Position backupPosition;
private Position currentPosition;
public Robot (int playerId, Position spawnPosition){
this.playerId=playerId;
this.backupPosition = spawnPosition;
this.currentPosition = spawnPosition;
}
public int getDamage(){
return robotDamageTaken;
}
public void setDamage (int damage){
this.robotDamageTaken = damage;
}
public Position getPosition(){
return currentPosition;
}
public void setPosition( Position newPosition ){
this.currentPosition = newPosition;
}
public void setPowerDown(Boolean powerDownStatus){
this.inPowerDown = powerDownStatus;
}
public Boolean isInPowerDown(){
return inPowerDown;
}
}

View File

@ -0,0 +1,22 @@
package inf112.fiasko.roborally;
import inf112.fiasko.roborally.element_properties.Position;
import inf112.fiasko.roborally.element_properties.Robot;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class RobotTest {
@Test
public void testRobotGetDamageOnInitializedRobot(){
Position robotPosition = new Position(3,6);
Robot testRobotGetDamage = new Robot(6, robotPosition);
assertEquals(0, testRobotGetDamage.getDamage());
}
@Test
public void testRobotSetDamage(){
Position robotPosition = new Position(3,6);
Robot testRobotSetDamage = new Robot(6, robotPosition);
testRobotSetDamage.setDamage(2);
assertEquals(2, testRobotSetDamage.getDamage());
}
}

View File

@ -6,7 +6,7 @@ import inf112.fiasko.roborally.element_properties.WallType;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class TestWall {
public class WallTest {
@Test
public void testWallGetWallTypeNormal(){
Wall testGetWall = new Wall(WallType.WALL_NORMAL, Direction.NORTH);