public class Main implements Observer{ public static void main(String[] args) { Main m = new Main(); Chronometer c = new Chronometer(2014, 7, 4, 13, 46, 21, (byte) 0); c.addObserver(m); c.run(); try { Thread.sleep(200000); } catch (InterruptedException e) { e.printStackTrace(); } } @Override public void update(Observable arg0, Object arg1) { int time = (int)arg1; if(time > 0){ System.out.println("Time left: " + time); } else { System.out.println("The time's over!"); //Update View } } }
chrono.addObserver(this);