|
-
Feb 13th, 2003, 10:34 AM
#1
Thread Starter
New Member
how to change a string in an array to int ??
Hi everyone, I am only learning java so please
excuse me if seems a silly question.
I have done a 2d array
start car destination time
Code:
{{london, ford, leeds, 90}
{london, vauxhall, ipswitch, 85}
{leeds, ford, manchester, 80}}
I know in an array all val's are of type string
what i need to do is a method to change time to int
ie. if i call london to leeds using ford it will
display time at 90, i would then want to call leeds
to manchester which should add 90 + 80 giving a time
of 170.
any idea's as I have been trying to find out how to make a object
in an arry and declare that object as a int(time)
would be grafull if any one can point me in the right direction
thanks
Lindsey
-
Feb 13th, 2003, 12:13 PM
#2
I have no idea what you want to do, but you're misusing arrays in the PHP way.
What you should have is a 1d array of objects of a class that looks like
Code:
public class Route
{
private String from;
private String to;
private String car;
private int time;
// and some public methods to make the class useful
}
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 13th, 2003, 03:16 PM
#3
Thread Starter
New Member
Thanks CornedBee,
It makes sense what you say, i will have a go at that myself
but my lessons in school have not covered the way you said as they went on about 2d and 3d arrays and then told us to do this home work. I know you will be right so I will try your way even if it upsets the teacher as i want to learn how you supposed to things the best way
thanks lindsey
-
Feb 13th, 2003, 03:27 PM
#4
You're learning Java and doing 2d arrays prior to classes 
Another terrible programming class...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Feb 13th, 2003, 03:37 PM
#5
Thread Starter
New Member
yes you are right, but i am learning a lot more about java from books and reading the post on this forum than from class which is why i feel silly coming on to ask questions all the time.
well i wish you all out their a good night
thank again for advise
lindsey
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|