Update Robot.java

Legger til felt for sjekk om en robot har besøkt et flagg i løpet av runden eller ikke.

Co-Authored-By: gabrielmagnus <gabrielmagnus@users.noreply.github.com>
This commit is contained in:
torlunjen 2020-04-09 19:56:33 +02:00
parent 1bac54b062
commit 9f843b8db6

View File

@ -16,6 +16,7 @@ public class Robot {
private Position backupPosition; private Position backupPosition;
private Position currentPosition; private Position currentPosition;
private Direction facingDirection; private Direction facingDirection;
private boolean hasTouchedFlagThisTurn = false;
/** /**
* Instantiates a new robot * Instantiates a new robot
@ -29,6 +30,23 @@ public class Robot {
this.facingDirection = Direction.NORTH; this.facingDirection = Direction.NORTH;
} }
/**
* True if the robot has touched a flag in the current turn
* @return a boolean
*/
public boolean isHasTouchedFlagThisTurn() {
return hasTouchedFlagThisTurn;
}
/**
* Sets the boolean value to true if the robot touches a flag during a turn,
* and false at the end of each turn.
* @param hasTouchedFlagThisTurn the boolean value to be set.
*/
public void setHasTouchedFlagThisTurn(boolean hasTouchedFlagThisTurn) {
this.hasTouchedFlagThisTurn = hasTouchedFlagThisTurn;
}
/** /**
* Gets the damage the robot has taken * Gets the damage the robot has taken
* @return The amount of damage the robot has received * @return The amount of damage the robot has received