Hi Folks
Continuing on in my attempt to build the Railroad application. I have several collections working of different types of classes (railroad, train, track, etc.) and I'm starting to try to figure out how to work with them now.
The main loop of the program is triggered on a timer to run every 10-20 seconds or so. In that loop the program is supposed to, among other things, look at each section of track in turn and determine if oe or more train is waiting to occupy it, and if so which train has priority (which will award authority to the track).
So - I have a collection of Authority objects in a collection (which are built from a collection of Schedule objects; as the time a train is supposed to leave a station hits a new authority object to the next station is created - but I digress), and what I want to do is look at the Authority collection and select all the objects that have the station in question as a property (which is not the lookup property you guys helped me with when I was creating te collection). I want to get a temporary collection or array of these specific object so I can process which one has the higher priority and update them.
If I were doing this as a Query from a DB I would write the statement as "SELECT Auth_ID FROM Authority WHERE Station_ID = 20", then iterate thru the data table and process it that way.
What are my options here? Create a temporary collection and copy the objects from the primary collection into it? I've read its also possible to create an array where the elements are defined as the same type of class, and then somehow you copy the objects out of the collection to the array?
How does one do something like this? My book is not very helpful in providing examples.
If I can learn to do this I will be able to re-use it very often in this project.
Thanks!
CraigHartz
Continuing on in my attempt to build the Railroad application. I have several collections working of different types of classes (railroad, train, track, etc.) and I'm starting to try to figure out how to work with them now.
The main loop of the program is triggered on a timer to run every 10-20 seconds or so. In that loop the program is supposed to, among other things, look at each section of track in turn and determine if oe or more train is waiting to occupy it, and if so which train has priority (which will award authority to the track).
So - I have a collection of Authority objects in a collection (which are built from a collection of Schedule objects; as the time a train is supposed to leave a station hits a new authority object to the next station is created - but I digress), and what I want to do is look at the Authority collection and select all the objects that have the station in question as a property (which is not the lookup property you guys helped me with when I was creating te collection). I want to get a temporary collection or array of these specific object so I can process which one has the higher priority and update them.
If I were doing this as a Query from a DB I would write the statement as "SELECT Auth_ID FROM Authority WHERE Station_ID = 20", then iterate thru the data table and process it that way.
What are my options here? Create a temporary collection and copy the objects from the primary collection into it? I've read its also possible to create an array where the elements are defined as the same type of class, and then somehow you copy the objects out of the collection to the array?
How does one do something like this? My book is not very helpful in providing examples.
If I can learn to do this I will be able to re-use it very often in this project.
Thanks!
CraigHartz