Design Patterns, Behavioural Design, Java, Software Development.
getState() { return state; } public void setState(int state) { this.state = state; notifyObservers(); } public void attach(Observer observer) { observers.add(observer); } public void detach(Observer observer) { observers.remove(observer); } public void notifyObservers() { for (Observer observer :