Rydder opp i brettet og testene

Overskriver toString metoden i Position for lettere debugging
Fjener removeDeadRobotsFromBoard siden den ikke ble brukt rett
Flytter repeterende elementer til variabler
This commit is contained in:
2020-02-27 10:38:26 +01:00
parent da99f11c51
commit c8f7dbbb87
3 changed files with 47 additions and 39 deletions

View File

@ -34,6 +34,11 @@ public class Position {
return yCoordinate;
}
@Override
public String toString() {
return String.format("X: %d, Y: %d", xCoordinate, yCoordinate);
}
@Override
public boolean equals(Object obj) {
if (obj.getClass() != Position.class) {

View File

@ -85,14 +85,6 @@ public class Board {
return getAllElementsFromGrid(walls);
}
/**
* Removes a dead robot from the board over to the dead robot list
* @param robot the dead robot
*/
public void removeDeadRobotFromBoard(Robot robot) {
robots.remove(robot.getRobotId());
}
/**
* Rotates a robot to the right
* @param robotID The id of the robot to rotate
@ -208,7 +200,7 @@ public class Board {
*/
private void killRobot(Robot robot) {
robot.setAmountOfLives(robot.getAmountOfLives() - 1);
removeDeadRobotFromBoard(robot);
robots.remove(robot.getRobotId());
deadRobots.add(robot);
}
@ -304,7 +296,6 @@ public class Board {
robot.setFacingDirection(Direction.NORTH);
robots.put(robot.getRobotId(), robot);
}
else {deadRobots.remove(robot); }
}
deadRobots = new ArrayList<>();
}