package cse1030; /** * A class that represents an alarm clock. The clock is a composition * of two SimpleTime objects (one for the clock time * and one for the alarm time). * * @author CSE1030 * */ public class AlarmClock { private SimpleTime time; private SimpleTime alarm; /** * Create an alarm clock with the given clock time and alarm time. * * @param clockTime the clock time * @param alarmTime the alarm time */ public AlarmClock(SimpleTime clockTime, SimpleTime alarmTime) { this.setClock(clockTime); this.alarm = new SimpleTime(alarmTime); } /** * Get the clock time. * * @return the clock time */ public SimpleTime getClock() { return new SimpleTime(this.time); } /** * Set the clock time. A client cannot modify the clock time * of the alarm clock using this this method. * * @param newTime the desired clock time */ public void setClock(SimpleTime newTime) { this.time = new SimpleTime(newTime); } /** * Get the alarm time. * * @return the alarm time */ public SimpleTime getAlarm() { return new SimpleTime(this.alarm); } /** * Set the alarm time. A client cannot modify the alarm time * of the alarm clock using this this method. * * @param newTime the desired alarm time */ public void setAlarm(SimpleTime newTime) { this.alarm = new SimpleTime(newTime); } }