Hello, I am a beginner with java in general, and I'm currently trying to create a randomly moving actor from the class "Crab" but I'm having some issues. I only want it to move up/down/left/right, and the problem is that it is only moving in one direction and not stopping until it touches the borders of the world. Here's my code for the "Crab" class:
Thank you in advance for your help :)
public void act()
{
int crabmovechoice = (Greenfoot.getRandomNumber(4));
switch (crabmovechoice)
{
case 1:
move(30);
crabmovechoice = (Greenfoot.getRandomNumber(4));
case 2:
move(-30);
crabmovechoice = (Greenfoot.getRandomNumber(4));
case 3:
setLocation(getX(),getY()-30);
crabmovechoice = (Greenfoot.getRandomNumber(4));
case 4:
setLocation(getX(),getY()+30);
crabmovechoice = (Greenfoot.getRandomNumber(4));
}

