hey everyone i'm a physics nerd and i'm working on some project that uses greenfoot as a visual aid. it's not complete yet but for testing purposes i'm trying to make an electron actor complete a loop around a circuit. i used a switch statement with a default setting but it will not complete the last part because i only have one case stated so once the actor moves out of the y value it no longer moves in the desired direction. i know i can specify hundreds of cases but that's highly inconvenient. i also tried using a for loop in the range of my desired y coordinates but it says i must use a constant. any ideas on how to make this work correctly?
public void move()
{
switch (getY())
{
case 532:
{
if (getX() != 359)
{
setLocation (getX() - 3, getY());
}
if (getX() == 359)
{
setLocation (getX(), getY() - 3);
}
break;
}
default:
if (getX() != 620)
{
setLocation (getX() + 3, getY());
}
if (getX() == 620)
{
setLocation (getX(), getY() + 3);
}
break;
}
