Hello there. I am trying to create a loop, which will move an objects position to a certain spot, based on a random number generator. Here is the code I have so far;
public void left()
{
if (this.getColour().equals(OUColour.WHITE)){
while(this.getPosition() !== this.setPosition(this.getPosition() - getRandomGenerator().nextInt(5) + 1)){
super.left();
}
}
}
So as you can see, I am trying to move the object a number of paces to the left, based on the the number generated from the random number generator. The movement must be done by using the getPos and setPos due to other methods restricting movement.
The errors I am receiving are 'illegal start of expression'. I also receive this same error when reduce the condition to simply this.getPos() !== this.setPos, making me think I have made a stupid mistake somewhere.
Any help is much appreciated. Thanks.