java - Using an Interface in another interface -


i not sure how proceed adding element priority queue. don't want code spoon feed me, can explain me how use interface passed interface parameter , class implementing 1 of method. please give me pointers, , learn how implement code.

queueitem class

 public interface queueitem        {       /**      * returns priority of item. priority guaranteed      * between 0 - 100, 0 lowest , 100 highest priority.     */      public int priority();      } 

priorityqueue class

 public interface priorityqueue        {      /**     * inserts queue item priority queue.     */     public void insert(queueitem q);      /**     * returns item highest priority.     */     public queueitem next();   } 

quickinsertqueue class

public class quickinsertqueue implements  priorityqueue  {      @override     public void insert(queueitem q) {         // todo auto-generated method stub      }      @override     public queueitem next() {         // todo auto-generated method stub         return null;     }  } 

i have write quickinsertqueue class implements priorityqueue interface having insert() method o(1).

you on right track. interfaces defined , class definition has correct implementation attached. since dont want code spoon fed applaud - next step want implement adding hashmap instance variable class, since underlying storage. , in method implementation insert, adding variable map.

eventually going need read generics.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -