I have a class "Sound", which I'm using for an audio engine. This is a basic sound object that contains nothing more than a file path to an audio file, and a Java Clip object to play that file.
I have a couple child classes to this class. For instance, a LoopSound has special variables and functions to facilitate the sound looping after it finishes. There's also MultiSound which is used for a sound effect that needs to be playing multiple instances at the same time, and has it's own set of variables and functions.
Naturally, there might be a Sound that both wants to Loop, and be multi, so I made LoopingMultiSound.
But then I had a 3rd idea, a Sound that you can apply a waveform to to get oscillating volume.
But that means, if I need a class that's any combination of these 3, I need to create that class. Which means I'd need to manually create all 8 classes. And for each function I want to add, that doubles the subclass count, which is not sustainable.
But I can't just pile all those functions into the original Sound object and just have a boolean saying if that child classes aspects are online or not. That would create a lot of clutter and kinda defeats the purpose of inheritance programming. I mean, there's nothing stopping me, and it's the simplest solution, but it's also the least elegant.
There's got to be a better way. How can I dynamically create grandchild class permutations?