Results 1 to 2 of 2
  1. #1
    Albert is offline Senior Member
    Join Date
    Jun 2007
    Posts
    114
    Rep Power
    0

    Default Like fighting with the tiped one of JAVA

    The problem is to implement a Observer pattern with two types of “dependents” that do not have anything to do to each other, the only thing that they share is a update() method . I am going to show it graphically, maybe you understand what am I talking about:

    Java Code:
    |--------------|               |--------------------|      |--------------| 
    |   Observer1  |               |        Model       |      |  Observer2   | 
    |--------------|               |--------------------|      |--------------|  
    |              |<---------     |dependents:ArrayList|  --->|              | 
    |--------------|               |--------------------|      |--------------| 
    |update():void |               |   changed():void   |      |update():void | 
    |--------------|               |--------------------|      |--------------|
    Java Code:
    public void changed(){ 
        Iterator it=dependents.iterator(); 
        while(ir.hasNext()){ 
             ______  object = (______) it.next(); 
             object.update(); 
        } 
    }
    any ideas? I want the solution without making 2 differents arrays.

    Albert:rolleyes:
    Last edited by Albert; 06-27-2007 at 05:36 PM.

  2. #2
    Marcus is offline Member
    Join Date
    Jun 2007
    Posts
    92
    Rep Power
    0

    Default RE: Like fighting with the tiped one of JAVA

    The solution that you are looking for is deciphers here:

    design-nation.blog/en: An example of the Observer pattern (the java version)

    Marcus:cool:
    Last edited by Marcus; 06-27-2007 at 05:40 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
  •