java - How can I change enum value inside it scope -
this enum class
public enum turn{ beginuserturn,userturn, beginenemyturn,enemyturn; public void change(){ if(this==beginuserturn)this=beginenemyturn; else this=beginuserturn; } } and have turn valiable
turn turn; turn=turn.beginuserturn; i want change turn value user enemy's turn call
turn.change() but problem in enum class,line 6,7 , have error
the left-hand side of assignment must variable
you can't reassign this. keyword, not variable. maybe try this:
turn = turn.change(); and have change() return next turn:
public turn change() { if (this==beginuserturn) return beginenemyturn; else return beginuserturn; }
Comments
Post a Comment