I have an enum Direction
which shows legal walking directions. With the helper-method turnLeft
I want to change the value of the called enum Variable, but it does not work: The value of the enum Variable direction
is the same after the call of the method.
enum Direction{
UP, RIGHT, DOWN, LEFT
}
private Direction direction = Direction.DOWN;
public void turnLeft(Direction direction) {
switch(direction) {
case UP: this.direction = Direction.LEFT; break;
case RIGHT: this.direction = Direction.UP; break;
case DOWN: this.direction = Direction.RIGHT; break;
case LEFT: this.direction = Direction.DOWN; break;
}
}
What am I doing wrong?