I'm having a bit of trouble with instances.
Im making a game in java where the user fights monsters, each monster has its own class file containing static reference info (health, attack, defense, introText and atkText), which are subclasses to the Monster class.
I start the fight with:
Monster current = new monster();
My problem being I have absolutely no idea what the monster will be and I don't want a switch case.
Can I do something like
Monster current = new getClassFromString(monster);
that ?
I'm not that good at Java (started yesterday), so I'm sorry if what I'm asking is hard to understand.
I use the classes like a database to store the basic info of a monster type/race, or like a lua table (im more used to lua):
Dragon = {"health"=100, "atk" = 25, "def" = 10}
Troll = {"health"=50, "atk" = 10, "def" = 0} //these exist in the files as classes
Monsters = { Dragon, Troll } //the ones before are subclasses of Monsters
//after the user selected the monster he wants to fight
current = Monsters[selected] //and now the table current contains all the info I need, without altering the stored one (in Dragon and Troll, and every other kind of monster)
Is there a way to do that in Java, but with the tables being classes?