There are several classes (Character1, Character2 ...) that implement the Actor interface. Everyone has a jump () method. How to call jump () from Character2 using a parameter?
1 answer
You will need type conversion (descending) and for convenience the class enum. Create an Actor person, and then, depending on the class you need, create the necessary one, ie:
Actor person; if(ActorType.CHARACTER1 == param) { //enum ActorType actor = new Character(); } else if(...) { ... } something like this...
|
Actor char2 = new Character2(); char2.jump();Actor char2 = new Character2(); char2.jump();? - Yuriy SPb ♦