We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I want to make many similar classes so I thought the solution would be to make them children of the same class. The thing is, with examples of "extends class", I've only seen child classes overriding methods. All my classes have the same meathods and constructor, but different setup, (they create audio players using different files). How do I override the data of a class?
It'd be really nice to stop having to copy and paste every time I change how these work.
Answers
The constructor can take parameters...
No need to extend in your case. If they have all the same functionality and different property (different song file name in this case), then you need a single class with a proper constructor as koogs suggested. Check the example below. Notice this is conceptual as I didn't test it. Notice I have to passed a reference to the current PApplet to my class as it is required by the SoundFile's constructor.
Kf