I have many classes which represent different kinds of animals. The idea is that if two animals of the same species meet then new animal of this species should be created - it means that I want to create a new intance of the specific class in this situation. If bears will meet i want to create new instance of bear, when bats meet then new instance of bat.
How can I achieve this goal without duplicating code? I want to avoid making individual if condition for each class (animal). I'm looking for the solution where new instance of a class will be created automatically based on the class of the existing instance.