nt period; private int seconds;
private PropertyChangeSupport propSupport;
/** * Getters and setters for model properties. */
/** * Returns the number of counted seconds. * * @return the number of counted seconds. */ public int getSeconds() { return seconds; }
/** * Sets the number of counted seconds. propSupport is an instance of PropertyChangeSupport * used to dispatch model state change events. * * @param seconds the number of counted seconds. */ public void setSeconds(int seconds) { propSupport.firePropertyChange("seconds",this.seconds,seconds); this.seconds = seconds; }
/** * Sets the period that the timer will count. propSupport is an instance of PropertyChangeSupport * used to dispatch model state change events. * * @param period the period that the timer will count. */ public void setPeriod(Integer period){ propSupport.firePropertyChange("period",this.period,period); this.period = period; }
/** * Returns the period that the timer will count. * * @return the period that the timer will count. */ public int getPeriod() { return period; }
/** * Decides if the timer must restart, depending on the user answer. This method * is invoked by the controller once the view has been notified that the timer has * counted all the seconds defined in the period. * * @param answer the user answer. */ public void questionAnswer(boolean answer){ if (answer) { timer = new Timer(); timer.schedule(new SecondsTask(this),1000,1000); running = true; } }
/** * Starts/stop the timer. This method is invoked by the controller on user input. */ public void setTimer(){ if (running) { timer.cancel(); timer.purge(); } else { setSeconds(0); &上一页 [1] [2] [3] [4] [5] 下一页
|