Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6748355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:33:18+00:00 2026-05-26T12:33:18+00:00

I made an Interface having all common methods a player should have. I implemented

  • 0

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 ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T12:33:19+00:00Added an answer on May 26, 2026 at 12:33 pm

    Explaning with your own scenario:

    Interface

    interface Player{
        public void play();
        public void pause();
        public void stop();
    }
    

    Classes which are implementing Player Intreface;

    class AudioPlayer implements Player{...}
    
    class VideoPlayer implements Player{...}
    

    Some extra class. Meaningless but seems relevant

    Class PlayList{}
    

    An enum who plays important role;

    enum MEDIAPLAYER {
        AUDIO,VIDEO;
    
        public Player getPlayer() {
            switch (this) {
                case AUDIO:
                    return new AudioPlayer();
                case VIDEO:
                    return new VideoPlayer();
                default:
                    return new AudioPlayer();
            }
        }
    }
    

    Using your code

    Player testPlayer = MEDIAPLAYER.getPlayer();
    :
    testPlayer.play();
    

    Now if any new player is added, its entry will go to MEDIAPLAYER which is returning Player type object. So everyone would have to implement Player

    Another approach:

    You can create an abstract class, say MasterPlayer, who is having all the abstract methods Player interface has. In addition, MasterPlayer will have some additional methods like managing PlayList

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made a generic Observer interface and an Observable class, but can't compile
I have made a custom formwizard and incorporated it into my admin interface. Basically
So I have made this simple interface: package{ public interface GraphADT{ function addNode(newNode:Node):Boolean; }
I've made an interface called ApprovalEvent in a separate file with the namespace myproject
I made a UIView using Interface Builder with a top bar that has Cancel
So I have made a webservice that interfaces with a set of data contained
So I'm writing yet another Twisted based daemon. It'll have an xmlrpc interface as
I'm having a difficult time wrapping my head around loading views with Interface Builder
I have an application that has several objects (about 50 so far, but growing).
So I have a UITabView Controller that was created in interface builder. The title

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.