Hey all, I'm trying to implement my half-understanding of arraylists, now that I've finished the chapter in Head First... The goal is to create 10 'mobs' (monsters) with random health and then be able to access those objects.
1. I have a class called MobInfo which is the attribute template for all monsters, it also includes a prototype of a 'spawner,' which gives them random health and a corresponding name.
2. I have a class called TestMobInfo which creates an MobInfo arraylist, then fills it with ten MobInfo objects which are created using the spawner. It also creates a MobInfo object which represents the player. It then (in theory) invokes the Attack class using the player MobInfo and the monster MobInfo, until all the monster MobInfos are dead and removed from the array.
3. The attack class is not included, because that part of the program doesn't even come into account. It doesn't come into account due to the fact that I can't for the life of me figure out how to use my new array of MobInfos. I tried everything from Mobs[4] to Mobs(NewMob.5) etc. etc. etc.
EDIT: By utilizing a for loop such as the one below, I can access the objects directly and print values such as their names. Are there other ways I should know about at this point in my
Java education? More importantly, am I still circling this concept as opposed to wrapping my mind around it?:
Here's the code, if it gives any context:
MobInfo.class: TestMobInfo.class: [ May 26, 2008: Message edited by: Alex Birmingham ]
[ May 26, 2008: Message edited by: Alex Birmingham ]
[ May 26, 2008: Message edited by: Alex Birmingham ]