abstract class A{protected List<B> list = new ArrayList<B>();
public void addObservables(Object o){
if(o instance of B)
list.add(o);
}
public void notifyObserver(){
if(!list.isEmpty()){
for(B b:list){
b.update();
}
}
public abstract void doWork();
}
}
interface B{
void update();
}
class c Extends A{
public void doWork(){
this.notifyObserver();
}
}
class D implement B{
public void update(){
}
}
|
|