|
Post by CooLiBoP on Jan 12, 2002 12:29:08 GMT -5
I was just wondering how my program will know the user typed a command swap or get because on the same like they are supposed to type numbers along with it...
i.e. if(x.equals("get")){ ... }
but how do I include the numbers after they type like "get 2"?
|
|
|
Post by 1.8T on Jan 12, 2002 22:40:31 GMT -5
look for a space in "x" , use substring???., i can't really remember,,., anyways., once u find a space in String "x" , your index would be wherever the space is,,., then u take the values after that space to the length of the String x, ?? and turn it into an int?
for swap, same deal , but instead of going to the length of the string X for the first value, u goto the next space..,
is this a valid way of doing it?.., i don't like to do it this way but i can only think of this.,..,,. any other suggestions? , an easier way?
|
|
|
Post by 1.8T on Jan 19, 2002 10:31:40 GMT -5
for the swap command,. when it swaps indices i and j, do they mean that if i have a vector of URLs followed by its title on the next index, that i can swap the location of the url and its title with another url and its title so kinda like this: where the numbers depict the indices 1 www.utoronto.ca/2 U of T Website 3 mat137.proboards.com/4 MAT137 Help Forum if i do swap 2 3 wouldn't i have: 1 www.utoronto.ca/2 mat137.proboards.com/3 U of T Website 4 MAT137 Help Forum or do the indices only apply to the url + title so that when swapping i acutally add 1 to index to get both the url line and its corresponding title line?? am i making this harder than it really is???,
|
|
|
Post by Sylph on Jan 19, 2002 16:05:16 GMT -5
ur probably supposed to do it the way that makes sense, i.e., always keep the url and its corresponding title together.
|
|
|
Post by Sylph on Jan 19, 2002 16:07:41 GMT -5
I was just wondering how my program will know the user typed a command swap or get because on the same like they are supposed to type numbers along with it... check the String class in the api.. there's a method that might make things a bit easier..
|
|
|
Post by Observer on Jan 20, 2002 2:39:42 GMT -5
On the hints page (the link above the handout on the CSC148 page) it says that there will be URL and title at each index in the question about swapping. WTF? I have my URLs as one element followed by the title in the next, I hope they don't mean what they've written.
|
|
|
Post by Brutal_Chicken on Jan 20, 2002 9:49:03 GMT -5
Hmm, well I suppose creating two vectors instead of one might be what they wanted but I just put it all in one vector.
I'm changing my code so that I'd have to deal with two vectors in the appropriate indices rather than have some confounded way to get both URL and List.
|
|
|
Post by Observer on Jan 20, 2002 10:33:01 GMT -5
Indeed that is what I am doing, this is a real pain.
|
|
|
Post by Brutal_Chicken on Jan 20, 2002 10:45:46 GMT -5
Note the singular referrence to a Vector or ArrayList. I think they do want it all in list.
Which brings me to my question; How to convert Integer to an int? Or more precisely, string to an int.
I've substring'd the part of the string where the numbers are supposed to be but I can't convert them to ints for the life of me. I've tried Integer.parseInt(substring) and several other weird conversions in between.
|
|
|
Post by 1.8T on Jan 20, 2002 10:48:49 GMT -5
are we suppose to save url in one index and title on the next??
but wouldn't it be easier if we store both on one line as one element of a vector., and when we need to output., we split it up?., cuz the swap and get commands will be hard to make., since u hafta make the indices of the title correspond to the url, and when outputting to a html file., the url and title are on the same line anyways., anyone did it this way?
|
|
|
Post by Sylph on Jan 20, 2002 10:53:47 GMT -5
i did it 1.8T's way. ;D everything works now.. except i have to start URLListTester.
|
|
|
Post by CooLiBoP on Jan 20, 2002 10:55:08 GMT -5
Note the singular referrence to a Vector or ArrayList. I think they do want it all in list. Which brings me to my question; How to convert Integer to an int? Or more precisely, string to an int. I've substring'd the part of the string where the numbers are supposed to be but I can't convert them to ints for the life of me. I've tried Integer.parseInt(substring) and several other weird conversions in between. it should be Integer.parseint <--- Notice NO CAPITAL I Its not Integer.parseInt ... its Integer.parseint!
|
|
|
Post by Observer on Jan 20, 2002 10:56:42 GMT -5
That certainly makes it easier.
|
|
|
Post by Sylph on Jan 20, 2002 10:58:51 GMT -5
it should be Integer.parseint <--- Notice NO CAPITAL I Its not Integer.parseInt ... its Integer.parseint! why doesn't Integer.parseInt work? it works for me..
|
|
|
Post by Brutal_Chicken on Jan 20, 2002 11:52:32 GMT -5
Well I tried parseint but the parseint method isn't in Integer, but parseInt works fine (not counting this case). Besides, why would parseint be a legal method that defies the syntax convention of java?
|
|