java hangman
I am trying to make hangman in Java. I have a file set up from which I read from, I then store the individual words in a vector.
I have tried to set up a loop that starts at 0 and goes to the word length, while in this loop I will check the letters and display them in the correct place.
I can compile and run it, although it seems quite slow, and it also gives me an "Array out of bounds, 0 >= 0" remark.
Unfortunately im quite new at this and things also seem to work......in theory.
www.geocities.com/toasted_terran/hangman.java
www.geocities.com/toasted_terran/hangman_graphics.java
(Tell me if you want the source on the forum, if you can''t get to it)
cheers
dude, i hope you aren''t trying to get someone to do your homework for you

OF course not, ive been trying to get this to work for about 3 months now.
hmmm sounds fishy to me ( homework) .... I will give you this for advice... read up on Exceptions and create a ''Try'' and ''Catch'' Block ...
Morpheus
try { //What ever it is your doing } catch {ArrayIndexOutOfBounds yada yada e) { //Whatever you decide to do System.out.println(e); } Finally { //Clean up }
Morpheus
----------
November 21, 2001 04:29 AM
I disagree with a_insomniacs advice in this case. Tho you generally should try to handle exceptions, ArrayIndexOutOfBounds usually shouldn''t be caught this way.
This exception is telling you that there is a fundemental problem with the code and that it should be fixed, not just handled. Handling it will stop the error being shown but it is far better fixing the error.
Check to see if you''re accessing an element beyond the size of the array. Be aware that array indexes usually start at 0, and check your loops to make sure that this is how you are handling it.
However, it is good advice to read up on exceptions even tho it is not applicable in this case
--
SC
This exception is telling you that there is a fundemental problem with the code and that it should be fixed, not just handled. Handling it will stop the error being shown but it is far better fixing the error.
Check to see if you''re accessing an element beyond the size of the array. Be aware that array indexes usually start at 0, and check your loops to make sure that this is how you are handling it.
However, it is good advice to read up on exceptions even tho it is not applicable in this case
--
SC
November 21, 2001 04:32 AM
quote: Check to see if you''re accessing an element beyond the size of the array. Be aware that array indexes usually start at 0, and check your loops to make sure that this is how you are handling it.
quote: I then store the individual words in a vector.
Sorry, I missed the fact that you were using a vector and assumed it was an array, so some of that info was incorrect. However, the advice is still broadly applicable.
--
SC
I appreciate the (limited) help guys. But I think im on to it now. The vector was fine it was something else...
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement