samedi 25 avril 2015

How to use Observable java


I have the following:

abstract class A extends Class C (abstract class C extends D).

private String name="";

public void setFff(double val) {

    double old = fff.getAvg();
    fff.update(val);

    ListIterator<Observer> it = fffListeners.listIterator();
    String ss;

    while (it.hasNext()) {
      ss = name + this.toString();
      it.next().update("fff", fff.getValue(), fff.getAvg(), ss);
    }
}

class B extends D implements Observable

private String name="";
public void notifyObservers() {
        for(Observer observer:fffListeners){
            v=fff.getValue();
             m=fff.getAvg();
            observer.update("fff", v, m, (name+this.getName()));
        }       
    }

interface Observer:

void update(String nn, double bbb, double aaa, String nameThraed);

abstract class E implements Observer

class G extends E.

update in class G is the following

public void update(String string, double v, double m, String s) {

        if ((B.getClass == "G")
                && string.equals("fff")&& (s.equals("B"))) {

             this.fffList.add(m);
            System.out.println("List of fff :" + fffList);

        }
    myMethod(fffList);
}

I want to get all the value of m and put theme in the list fffList when I get a notification from E. How can i do that?


Aucun commentaire:

Enregistrer un commentaire