Or you could just have a "toWarrior()" method on your Wizard class (and vice versa) which returns a new warrior object and do something like this (myCharacter is of type character, currently representing a wizard instance):
Whether this is feasible (or even desirable) depends entirely on how your data is modeled - but in the absence of duck typing / dynamic typing, there isn't really much you can do about it.
myCharacter = myCharacter.toWarrior()Now myCharacter is of type character, but it represents a warrior instead.
Whether this is feasible (or even desirable) depends entirely on how your data is modeled - but in the absence of duck typing / dynamic typing, there isn't really much you can do about it.