So I know that reference variables cannot be changed.
I'm in a position where I have two different classes. Let's call them A and B. They have the same methods (the methods are called the same) they're just specified for the class.
I need a clever way of changing between which classes to instantiate.
One way could be with some boolean tests checking which option has been selected and then instantiate the corresponding class. Although I fear that this might become bulky and ugly, so I'm trying to avoid this way. There must be something more clever.
Currently I'm thinking of making a new class (e.g. C) that extends the same class as A and B.
I would then override the methods (as class A and B also do btw) and then execute the methods depending on the setting (i.e. which class A or B is selected). The methods would return the same as it would in class A or B.
Hope I'm not talking complete gibberish.