|
-
Feb 8th, 2003, 06:16 PM
#1
Thread Starter
New Member
how do you do a 3 dimensional array
Code:
What the right way to declare a 3 dimensional array
i.e
depot name bus no destination journey time
crewe 80a London 120
crewe 70 liverpool 90
crewe 60b Newcastle 50
Manchester 40c Glasgow 90
Glasgow 40c leeds 45
Would it be
String[] buses = {{ crewe , 80a, London, 120},
{crewe, 70, Liverpool, 90},
{crewe, 60b, Newcastle, 50},
{Manchester, 40c, Glasgow, 90},
{Glasgow, 40c, leeds , 45},};
is it the way you would do it, because each depot could have up to 5 buses
leaving each day, I would have to leave room for 5 buses in each depot
this must be wrong. As I would end up with
{{ crewe , 80a, London, 120},
{crewe, 70, Liverpool, 90},
{crewe, 60b, Newcastle, 50},
{crewe, 0, 0, 0},
{crewe, 0, 0, 0},
3 depots using 15 rows * 4 colums is that right
-
Feb 8th, 2003, 07:57 PM
#2
Addicted Member
You will need three sets of brackets [] to use a 3D array.
String[][][] threeD; // threeD is a 3D array.
See http://vbforums.com/showthread.php?threadid=221865
private static boolean[][][] blockLook = {
{ { true, true, true, true},
{false, false, false, false} },
{ { true, true, true, false},
{ true, false, false, false} },
{ { true, false, false, false},
{ true, true, true, false} },
{ {false, true, true, false},
{ true, true, false, false} },
{ { true, true, false, false},
{false, true, true, false} },
{ {false, true, false, false},
{ true, true, true, false} },
{ { true, true, false, false},
{ true, true, false, false} }
};
When I first replied there, I didn't realize that the comments were showing a graphic for true and false, so I left out the comments here. This is a 7x2x4 array. It looks like you want a 3x15x4 array.
-
Feb 8th, 2003, 10:07 PM
#3
New Member
thanks Phenix
I will go to bed now and have a go tomorrow again, well I wish you all out their a good night
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
|