#jagged arrays, lists and classes
1 messages · Page 1 of 1 (latest)
so that means either classes or a list of lists is the best way to store? the only way as of now that I have a remote idea of how to do it is by using a triple jagged array
jagged arrays, lists and classes
@robust prism I'm not quite sure what you mean with classes for this purpose
do I just google classes in general and I should be able to understand?
well you already wrote it out. a class named Group with a List of Bus, and Bus is a class with a List of Time. That way you can easily add functionality to each sub item. it also makes it easier to read
Group[0].Bus[1].Time[0]
compared to:
Array[0][1][0]
ah
alright so I guess I gotta learn about classes
now that I say it out loud I wonder how I got so far without knowing what classes are
if I split them into classes, I still have to create a list right?
or at least a single array?
ye
because the amount of elements is unknown, and up to the user to create
it would be amazing if there were some way for the code to just auto-create more variables ;-;
after storing the data I also need to be able to sort the data by the int size, and pull the corresponding group and bus name too
so I'm guessing the class can store more than just the array, such as a string for the name, right? which I can then pull later
yes
alright, I'll give this a shot for now, although I have no idea what I'm mostly doing
List are already self expanding
time for mr google to hold my hand
so do I use a list or array?
both should be usable, right?
I kinda wanna stick to arrays because it's what I'm used to, but lists seem better fit for the task
there isn't really any good reason to use an array. A list does the same but better
mhm. so I guess I'll make 3 classes, and fill them each with a list corresponding to the data type: group, bus or timeslot
then I can create an instance of the class and fill it with data as the user creates more of the items?
ye pretty much