I made an Interface having all common methods a player should have. I implemented it in my code, my colleague too. But many of the developers who were not aware with my interface created their own methods like playMyPlayer() etc.
How can I force other programmers to implement my interface ?
Explaning with your own scenario:
Interface
Classes which are implementing
PlayerIntreface;Some extra class. Meaningless but seems relevant
An enum who plays important role;
Using your code
Now if any new player is added, its entry will go to
MEDIAPLAYERwhich is returningPlayertype object. So everyone would have to implementPlayerAnother approach:
You can create an abstract class, say
MasterPlayer, who is having all the abstract methodsPlayerinterface has. In addition,MasterPlayerwill have some additional methods like managingPlayList