need help with ending a game
i'm making a game at the moment.......
i need help with a way to check all the hashmaps of enimies in a class called room......i need to check if they all == 0...when they all equal zero the game ends......
i know i can check the size of a hash map with size().....but i want to check if all the hashmaps within all the rooms == 0.
[351 byte] By [
mollemana] at [2007-11-26 20:31:12]

First of all stop cross posting. These values in the HashMap, they are a "Collection" of values, so what is wrong with reply two and putting all these collections of values into a super collection? A collection of collections? You can have a HashMap of HashMaps. One HashMap that holds all your maps and then you can use a for loop to check if they are empty. A map is probably a bad choice for this operation as you don't need a key and an array will be much faster.
HashMap [] allMaps = {new HashMap(),new HashMap()};
> so what is wrong with reply two and putting all these
> collections of values into a super collection?
In this case, I'd probably recommend encapsulating the maps (or, more likely, collections) in a Room object, enabling one to iterate through the rooms, calling hasMonsters(), or some such thing.
Example:boolean hasMoreMonsters() {
for (Room r : rooms) {
if (r.hasMonsters()) return true;
}
return false;
}
~