I want to make a unit test for a game I have made, this code below is a simple move command for a grid-based game whereby when the user clicks a button the method is attached to, the player is moved up 1 row.
public String moveUp() { //Allows player to move when corresponding command is entered
int targetRow;
int targetCol;
targetRow = goldMiner.getRow() - 1;
targetCol = goldMiner.getCol();
String response = "";
//If player does not have enough stamina they will not be allowed to move
if (goldMiner.getStamina() <= 0) {
response = "You are out of Stamina";
//Stops player from moving outside of map
} else if (targetRow < 0) {
response = "You can't move that way";
//If all parameters are met allows player to move in corresponding direction
} else {
PlayerMove(targetRow, targetCol);
response = "You moved Up";
}
return response;
}