This is somewhat related to my previous question but I've realised that I needed to deal with the issue of nesting earlier in the problem, so here's where I am. (I'm also not far off being a beginner in Java, so please bear with me).
I'm creating a simple booking system for 5 rooms which will take in names, times, room numbers and days. This has to be done using nested TreeMaps. Here's the layout of the data as I see it, where paretheses represent the boundaries of a TreeMap:
(Day, (Room #, (Time, Name)))
As far as I can see, I need one TreeMap for times and names, one for each room, then one for each day. That means one time/name treemap per room per day, which means 1 x 5 x 7 = 35 TreeMaps. Like this:
{Mon, [Room 1, (0600, NameA
0630, NameB
0700, NameC)
Room 2, (0600, NameD
0630, NameE)
Room 3, (0600, NameF
0630, NameG)]
Tues, [Room 1, (0600, Name1
0630, Name2)
Room 2, (0600, Name3
0630, Name4
0700, Name5)]}
(the different bracket types represent the boundaries of the nested TreeMaps)
Having come to that conclusion, my next problem is iterating through a loop to create all those TreeMaps. I can't seem to dynamically generate the TreeMaps using a for loop, because I can't stick a counter's variable number onto the newly-created TreeMap's name.
I did have this:
TreeMap keyDay = new TreeMap();
TreeMap keyRoom = new TreeMap();
TreeMap keyTime = new TreeMap();
but it is only three, which is clearly not enough to allow for duplication of keys - any new entries for e.g. '0900' (time key) or e.g. 'Room 1' (room key) will overwrite the old ones.
Does anyone have any suggestions? Would be much appreciated :)