The advantage of using ArrayLists is that if you don’t have anything in the list then it doesn’t cause any problems. So you don’t really have to worry if one is empty. I think trying to do this all through a constructors would be difficult. You can modify a level after creating it like:
Level[] levels = new Level[100];
void setupLevels() { // call in setup
levels[0] = new Level(player[0], goals[0]);
// Could add play and goals in constructor if each level has one.
for (int i = 0; i <= 3; i++) {
// will add walls 0 through 3 to level 0 (or 1 depending on numbering)
levels[0].walls.add(walls[i]);
}
// skipping a couple levels
// level 7 (or 8 depending on numbering)
levels[7] = new Level(player[0], goals[1]);
for (int i = 2; i <= 4; i++) { // could reuse walls
levels[7].walls.add(walls[i]);
}
levels[7].walls.add(walls[10]); // could add some other walls not in range
levels[7].keys.add(keys[2]);
levels[7].keys.add(new Key(xLocation, yLocation)); // can create an object inline
// then do similar stuff for other levels
}
Does that make sense? I’m not sure if it helps or not.