/**
 * A GUI window that contains an alarm clock
 * with a digital display
 *
 * @author  
 * @version 1.0
 */
public class AlarmClock extends Clock
{
    private boolean    on;
    private int        hour, minute, second;
    private String     ampm;



    /**
     * Default Constructor
     */
    public AlarmClock()
    {
        super();
    }


    /**
     * Explicit Value Constructor
     *
     * Constructs a clock for a particular city, setting
     * the time zone appropriately
     *
     * @param city   The city
     */
    public AlarmClock(String city)
    {
        super(city);
    }

  /**
     * Set the alarm
     *
     * @param hour     The hour of the alarm
     * @param minute   The minute of the alarm
     * @param second   The second of the alarm
     * @param ampm     "AM" for before noon, "PM" for noon and after
     */
    public void setAlarm(int hour, int minute, int second, String ampm)
    {
        this.hour = hour;
		  this.minute = minute;
		  this.second = second;
		  this.ampm = ampm;    
    }


    /**
     * Turn the alarm off
     */
    public void turnAlarmOff()
    {
      	on = false;
    }



    /**
     * Turn the alarm on
     */
    public void turnAlarmOn()
    {
    	on = true;
    }

  /**
     * Update the time displayed on the clock
     */
    public void updateTime()
    {
	int         hourNow, minuteNow, secondNow;
	String      ampmNow;

	// Call the parent's version of updateTime()
        super.updateTime();
        hourNow = getHour();
        minuteNow = super.getMinute();
		  secondNow = super.getSecond();
		  ampmNow = super.getAMPM();
	// If the alarm is on, get the current hour, minute
	// second, and ampm and check to see if the alarm
	// should sound now
	     if  (on) 
		  {
		     if ( (this.hour == hourNow) && 
			       (this.minute == getMinute())  &&
					 (this.second == super.getSecond()) &&
					 (this.ampm.compareTo(ampmNow)== 0)
				   )   
            
				{ 
				 System.out.println (" alarm should sound now ");
				 super.beep();
				} // END inner if 
        } // END outer if
   }// END updateTime
    
}  //END AlarmClock
