+ 11
Can someone shed some light on my problem?
I seem to be losing the correct values of my private variables somewhere inside my do...while loop, they keep getting zero'd out. https://code.sololearn.com/c22FNtmaFPkQ/?ref=app
2 Réponses
+ 2
the prob of your code is you declared these variables before setting up your objects(calling the class choice)
int aAtk = a.getAtk();
int aDef = a.getDef();
int aHp = a.getHealth();
String aSp = a.getSpec();
int bAtk = b.getAtk();
int bDef = b.getDef();
int bHp = b.getHealth();
String bSp = b.getSpec()
if you put them after giving users value to your fighter objects it would work just fine.
by the way nice idea!
+ 1
however i suggest you change the objects instead of changing these variables
i saw you had a method called get damage you can use this method to actually change your private attributes of your object