java - Static array declared but method cannot work -
I have to do my homework in chess < / Code> needs to be saved and then click Reset.
Then, I have to load the chess piece back to the position before resetting.
Since I do not know the exact size of the array, I know that I do not have permission in list
but homework
Nothing was shown on the screen but no Error message is not
Assume that I have a class named chess
.
Steady actor [All Chase; Public Zero Save () // It is left [actor [] allChess = GWorld.getAll object ("chess"); } Public Zero Load () / / This is loaded (if (All Chas! = Null) {for (ii) I & lt; allChess.length; i ++) {Chess ch = (Chess) All Chas [i]; GWorld.addOneObject (new chess (ch.color, ch.rank), ch.getX (), ch.getY ()); }}}
Thanks a lot!
all chas
is redeclared as local code Save ()
. Do this:
Save public zeros () // Save it {allChess = GWorld.getAllObjects ("Chess"); }
Comments
Post a Comment