I have been given data that is water stream quality in Ontario. Any time station is mentioned I am refering to a place at which data was taken. Any time result is mentioned I am refering to the data that had been collected.
I have an array with the following:
String[] stationArray = {1049, 05/12/2004, 13:50}; //{station id, date, time}
I would like to make this into an object. If I knew what the station id would be all the time, I would do this (assuming I have a station class):
String date = "05/12/2004;
String time = "13:50";
Station 1049 = new Station(date, time);
But I don't know what the station id will be as I have 2000+ stations (and 100 000+ results) and I don't want to hard code the numbers into the program. So how can I do something that accomplishes this:
String date = "05/12/2004";
String time = "13:50";
String station_id = stationArray[0]; //this way I can pop each array into a function to create the Station object for me
Station station_id = new Station(date, time);
If I was able to do this, I would send the array to a function and create the objects that way because I could change the station_id
variable for each object. The reason I want to do this is because I have another class Result
which has several properties including the station id the data was gathered at (which is of type Station
). This may not be the best way to use the data but I must show a has-a
relationship and this is the only opportunity I can find to use it.
At the end of it all, I was hoping I could use something like...
result.station_id.location //where station_id is of type Station
...to find where a set of data was taken. If station_id is a String
, I would have to take it and compare it to an array of Station
's then find the location that way.