Results 1 to 4 of 4

Thread: interface help

  1. #1
    alpdog14 is offline Member
    Join Date
    Mar 2009
    Posts
    57
    Rep Power
    0

    Default interface help

    So I have following code fragement:

    Java Code:
    LibraryFactory f = new DefaultLibraryFactory();
    Library l = f.createArchive(
       			f.createSong(),
       	f.createSong(),
       	f.createGroup(3, f.createSong())
          );
    I need to develop a LibraryFactory interface to make this work, I tried to develop this:

    Java Code:
    interface LibraryFactory { 
    
    	
    Object createSong();
    
    	Object createGroup(int i, Object createSong);
    
    	Library createArchive(Object createSong, Object createSong2,
    	Object createGroup);
    
    }
    Somethings seems off to me, can any guide me in the right direction?
    Last edited by alpdog14; 05-03-2011 at 08:38 PM.

  2. #2
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    No, it looks quite alright to me.. I just think interfaces maybe simpler than you think

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    As ozzy said, your interface looks fine. Interfaces are actually fairly simple. All they do is list a bunch of abstract method and any class that implements them is responsible for providing a definition for each method.

    Would you mind saying what you think seems off?

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    Well, for starters, I would suggest all those Object objects you are using are wrong. Shouldn't a song be a Song class, and a group a Group class?

Similar Threads

  1. Interface?
    By maknib in forum New To Java
    Replies: 52
    Last Post: 11-05-2010, 10:22 AM
  2. How do I use an Interface for this?
    By aaronfsimons in forum New To Java
    Replies: 14
    Last Post: 06-22-2009, 02:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •