Can you include more than one variable in a switch
statement in Java?
enum Facing { North, South, East, West }
enum Forward { Right, Left }
Forward forward;
Facing facing;
Integer myNumber;
So it looks like this? And if so how would I go about implementing
switch (facing, forward) {
case North, Right : facing 1 = East
}
I know this is wrong but wondered whether such a technique might work and how would I implement it?
You can do like this:
switch(facing)
{
case North:
switch(forward)
{
case Right: // blah blah
break;
}
break;
}