From 9c5a2b60e740f26c065ae427c5af8067858c13d6 Mon Sep 17 00:00:00 2001 From: EpicKnarvik97 Date: Sat, 22 Feb 2020 23:37:03 +0100 Subject: [PATCH] =?UTF-8?q?Oppdaterer=20Robot=20til=20=C3=A5=20bruke=20en?= =?UTF-8?q?=20RobotID=20i=20stedet=20for=20en=20playerId=20int?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fiasko/roborally/objects/Robot.java | 25 ++++++++++--------- .../fiasko/roborally/objects/RobotTest.java | 5 ++-- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/java/inf112/fiasko/roborally/objects/Robot.java b/src/main/java/inf112/fiasko/roborally/objects/Robot.java index 4190819..12d7d1a 100644 --- a/src/main/java/inf112/fiasko/roborally/objects/Robot.java +++ b/src/main/java/inf112/fiasko/roborally/objects/Robot.java @@ -1,13 +1,14 @@ package inf112.fiasko.roborally.objects; import inf112.fiasko.roborally.element_properties.Position; +import inf112.fiasko.roborally.element_properties.RobotID; /** - * this class represents a robot + * This class represents a robot */ public class Robot { private int robotDamageTaken = 0; - private final int playerId; + private final RobotID robotId; private boolean inPowerDown = false; private int lastFlagVisited = 0; private Position backupPosition; @@ -15,11 +16,11 @@ public class Robot { /** * Instantiates a new robot - * @param playerId gives the robot a identifier that links it too the correct player + * @param robotId gives the robot a identifier that links it too the correct player * @param spawnPosition gives the robot its starting position on the map */ - public Robot (int playerId, Position spawnPosition){ - this.playerId=playerId; + public Robot (RobotID robotId, Position spawnPosition) { + this.robotId = robotId; this.backupPosition = spawnPosition; this.currentPosition = spawnPosition; } @@ -33,7 +34,7 @@ public class Robot { } /** - * Set the robot's damage too a given amount + * Sets the robot's damage to a given amount * @param damage the amount of damage the robot has received */ public void setDamage (int damage){ @@ -78,8 +79,8 @@ public class Robot { * @param newBackupPosition the position of the flag */ public void setLastFlagVisitedAndBackupPosition(int currentFlag, Position newBackupPosition){ - this.lastFlagVisited=currentFlag; - this.backupPosition=newBackupPosition; + this.lastFlagVisited = currentFlag; + this.backupPosition = newBackupPosition; } /** @@ -91,8 +92,8 @@ public class Robot { } /** - * Gets the robots backup position - * @return robots backup position + * Gets the robot's backup position + * @return The robot's backup position */ public Position getBackupPosition(){ return backupPosition; @@ -102,8 +103,8 @@ public class Robot { * Gets the identifier of the players controlling the robot * @return player identifier */ - public int getPlayerId(){ - return playerId; + public RobotID getRobotId(){ + return robotId; } } diff --git a/src/test/java/inf112/fiasko/roborally/objects/RobotTest.java b/src/test/java/inf112/fiasko/roborally/objects/RobotTest.java index 4d96dec..b07529e 100644 --- a/src/test/java/inf112/fiasko/roborally/objects/RobotTest.java +++ b/src/test/java/inf112/fiasko/roborally/objects/RobotTest.java @@ -3,6 +3,7 @@ package inf112.fiasko.roborally.objects; import inf112.fiasko.roborally.element_properties.Position; import static org.junit.Assert.assertEquals; +import inf112.fiasko.roborally.element_properties.RobotID; import org.junit.Before; import org.junit.Test; @@ -12,7 +13,7 @@ public class RobotTest { @Before public void setUp(){ robotPosition = new Position(3,6); - testRobot = new Robot(6, robotPosition); + testRobot = new Robot(RobotID.ROBOT_6, robotPosition); } @Test public void testRobotGetDamageOnInitializedRobot(){ @@ -20,7 +21,7 @@ public class RobotTest { } @Test public void testRobotGetPlayerId(){ - assertEquals(6, testRobot.getPlayerId()); + assertEquals(RobotID.ROBOT_6, testRobot.getRobotId()); } @Test public void testRobotGetBackupOnInitializedRobot(){