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]
# 1
CROSSPOST: http://forum.java.sun.com/thread.jspa?threadID=5144273
DrLaszloJamfa at 2007-7-10 1:21:11 > top of Java-index,Java Essentials,New To Java...
# 2
Why not put them in an array or another Hashmap and iterate though them in a method to check if they are all emtpy?
kikemellya at 2007-7-10 1:21:11 > top of Java-index,Java Essentials,New To Java...
# 3
-removed-Message was edited by: prometheuzzmolleman, why do you keep crossposting? Knobjockey!
prometheuzza at 2007-7-10 1:21:11 > top of Java-index,Java Essentials,New To Java...
# 4
> an, why do you keep crossposting? Knobjockey!I think you answered your own question.EDIT: Maybe he needs help ending a post also.Message was edited by: kikemelly
kikemellya at 2007-7-10 1:21:11 > top of Java-index,Java Essentials,New To Java...
# 5
could someone please help me... i still dont know what to do
mollemana at 2007-7-10 1:21:11 > top of Java-index,Java Essentials,New To Java...
# 6
> could someone please help me... i still dont know what to doAnswered in your other thread.~
yawmarka at 2007-7-10 1:21:11 > top of Java-index,Java Essentials,New To Java...
# 7

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()};

kikemellya at 2007-7-10 1:21:11 > top of Java-index,Java Essentials,New To Java...
# 8

> 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;

}

~

yawmarka at 2007-7-10 1:21:11 > top of Java-index,Java Essentials,New To Java...