I'm currently stuck on a Java program. My program, a city-builder game, needs the ability to instantiate objects at any moment based on the user's whim, and the number of objects needs to be infinite.
The program is going to have a Building type object.
(I know how to instantiate new objects; like so...
Building building1 = new Building();
...)
However, this methodology isn't acceptable for my program. My program needs to be able to instantiate new Building objects on the fly. Imagine the user has the option to click on a button that places a new Building into the world. They could click to place a new Building into the world zero times, or they can click 5,000 times, consequently placing 5,000 Buildings into the world.
I obviously don't want to have to instantiate 5,000 objects, like so:
Building building1 = new Building();
Building building2 = new Building();
...
Building building5000 = new Building();
Any suggestions to how you might code it? Thanks in advance!