|
Post by Observer on Feb 21, 2002 12:59:11 GMT -5
I need to change my main method in Assignment one since it was a bit long by breaking it into smaller methods but whenever I change anything I'm greeted with endless (runtime) stringindexoutofbounds exceptions. Can anyone think of reasons behind this exception occuring and what I need to do to make sure it doesn't happen?
|
|
|
Post by Bahamut on Feb 21, 2002 18:32:58 GMT -5
That is weird. I'll tell you what I did: I broke up all the options ("add", "list", etc...) into STATIC methods. Each variable that these methods use also has to be static. That's all I did and it worked. StringIndexOutOfBounds sounds like you're trying to take a substring of a string and the index used is beyond the string's length...? I didn't get that error when editing my A1Driver.
|
|
|
Post by Observer on Feb 21, 2002 18:39:29 GMT -5
I figured out the problem literally 15 minutes ago after almost going insane, and the problem was I see just what you described (couldn't you have been here a few hours ago!? ;D). My get and swap commands were taking substrings but when I was typing in words that weren't as long as the substring section so the string index was out of bounds. I think I lost a mark of that in the automarker (lucky it didn't damage my mark any further). It was easy to correct, just by adding an if (string.length() >= whatever). That was agravating.
|
|
|
Post by Brutal_Chicken on Feb 22, 2002 11:47:43 GMT -5
Yeah those are a pain. You gotta make sure that it's either at least n long and the first words are whatever... You better make sure that the input length is at least the length of word + space + number for get().
|
|
|
Post by 1.8T on Feb 23, 2002 16:27:54 GMT -5
question: for A1 ., we were told the URL and its title will be on one line from the html file but for A2, we were told that it can extend to next line . for A1, the program won't work when the url+title extends to multiple lines of the file.. so my question is for A3., they won't screw us over wtih multiple line url+titles right? .
|
|
|
Post by Bahamut on Feb 23, 2002 20:06:10 GMT -5
>>>so my question is for A3., they won't screw us over wtih multiple line url+titles right?. <<<
The only changes you have to make is use a linked list and iterator. Everything else is the same.
|
|
|
Post by Observer on Feb 27, 2002 4:29:18 GMT -5
Umm, Bahamut I just noticed you said you used static methods for the commands. Are those methods in your A3Driver? You know, that you can't have static methods in any other classes yeah (vital rules)?
I hope you know about that. I'm finally virtually done (and it's 4am in the morning!) Everything is working correctly, apart from one little thing. I see the end of the tunnel at last. A few more comments to add and done. Considering we have till 6pm to submit it tommorow, it seems I didn't have to stay up afterall.
|
|
|
Post by Bahamut on Feb 27, 2002 17:32:28 GMT -5
You know, that you can't have static methods in any other classes yeah (vital rules)? Yeah. It's sweet of you to worry about me.
|
|