Hi all,
just trying out a switch statement, my question relates to the case element. How can the case use an operator like >= or <= ? As I'm trying to add different enemy patterns based on the random number selected. You can see my attempt below which work only with a =
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | if (selection == 1 ) { int enemySelection = Greenfoot.getRandomNumber( 10 ); switch (enemySelection ) { case 1 : enemySelection = 6 ; moveLeft(); break ; case 2 : enemySelection = 5 ; moveLeftDown(); break ; } enemyBoundary(); } } |