I have some C++ code I am porting to Java.
My code looks something like this@
enum direction {UP, DOWN, LEFT, RIGHT, NEUTRAL};
int LINK[5];
.....
//fill LINK array
.....
if (desired_direction == LEFT ) || (LINK[LEFT] > 0) return true;
if (desired_direction == RIGHT ) || (LINK[RIGHT] > 0) return true;
if (desired_direction == UP ) || (LINK[UP] > 0) return true;
if (desired_direction == DOWN ) || (LINK[DOWN] > 0) return true;
So I have an array filled with ints and I am using an enum for the index of the array.
What is the Java way of going about this?
Thanks
Basically, nothing is different.
In fact the only things missing here are the parenthesis around the two conditions of each
ifstatements.Also, your call to the enum value will be
direction.whatever.ordinal()instead of justwhatever.