I'm working on a game to learn the basic for game concepts. I end up with the following problem. I got a class called enemy, but now I want different types of enemies. These enemies extend from this class enemy. So I can have different enemies with that share different properties. The problem is that I want to spawn a different enemy each time. But to do this I need to know all the enemies available to choose on randomly.
I have been thinking and I got two approaches to solve this. The first one I end up is to have an enum with different enemies, and get a random value from the enum and spawn that enemy, but for this, I need to hard code all the enemies into the enum. And another one is to have a GameRegister class, that have a register for all available enemies, like when you do modding in Minecraft for example. I can have a registered class to register enemies or objects. And if I want to select a random enemy I know all the enemies available. I think is the best approach because if I want to add more enemies or anything, I only need to register for that class.
I don't have any idea at all to how to implement this pattern, and I didn't find anything on the internet. Can someone give some tips or clarify what I want to do? Because I have the main idea but I get completely lost when I need to design this.
I'm working on Java using libGDX, if is useful for some reason.