How do I refer to an integer named in a String?
in
Programming Questions
•
2 years ago
So I've got the following variables.
int upgradeLvl - this changes, so it could be anything from 1-5.
int dmg1, dmg2, dmg3, dmg4, dmg5 - these are the values of the damage each class does, "dmg1" refers to the damage at level 1, dmg2 at level 2 and so on. This is so that I can easily manipulate and balance these later.
int dmg - the current dmg of the tower.
finally
String currentDmg = "dmg"+upgradeLvl; At upgradeLvl=1, String currentDmg = "dmg1", etc.
Then I want to go..
dmg = currentDmg (ie. dmg = dmg1, or dmg2, etc. depending the level).
but I can't make an int equal to a String "dmg1", I need it to refer to the variable named "dmg1" and extract the data from that.
Sorry if this is badly explained. Help would be much appreciated.
1