import java.awt.*; import java.util.*; public class ObserverPlan implements Observer { private Hashtable table; private char axe; public ObserverPlan(char axe){ this.axe = axe; table = new Hashtable(); } public void update(Observable o, Object arg){ update((Volume)o,arg); } public void update(Volume o, Object arg){ if ((arg==null) || (((Character)arg).charValue()!=axe)){ table.put(Integer.toString(o.hashCode()),o.getSurface(axe)); System.out.println("surface perpendiculaire à l'axe "+ axe+ " = "+ surface()); } } public int surface(){ int res = 0; for (Enumeration e = table.elements() ; e.hasMoreElements() ;) { res += ((Integer)e.nextElement()).intValue(); } return res; } }