How to use Observable java -
i have following:
abstract class 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> = 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 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 value of m
, put theme in list ffflist
when notification e
. how can that?
extend interface:
void update(object sender, string nn, double bbb, double aaa, string namethraed);
in special case can check if sender instance of class e.
if(sender instanceof e){ ... }
hope you. , please refactor parameters:)
Comments
Post a Comment