dimanche 7 août 2016

Call all classes that implement an interface

I have the following code in place.

Interface Vehicle which has a method calculateDistance.

Class Car implements Vehicle Class Bicycle implements Vehicle Class MotorCycle implements Vehicle

What I want to do next is a method in my controller that calls every class that implements Vehicle and get the values from calculateDistance.

What would be the best way/design pattern to achieve this?

Aucun commentaire:

Enregistrer un commentaire