/**
* A GUI window that contains an alarm clock
* with a digital display
*
* @Elizabeth Adams
* @version 1.0
*/
public class AlarmClock extends Clock
{
	private boolean on;
	private int hour, minute, second;
	private String ampm;

/**
* Default Constructor
*/
	 public AlarmClock()
 	{
		// call parent default constructor
     super();
 	}
/**
* Explicit Value Constructor
*
* Constructs a clock for a particular city, setting
* the time zone appropriately - think about what the parent does
*
* @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)
	{
      /*  // copy of attributes
			private boolean on;
	      private int hour, minute, second;
	      private 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();
	
// 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) 
	{
		    hourNow = super.getHour();
			 minuteNow = super.getMinute();
			 secondNow = super.getSecond();
			 ampmNow = super.getAMPM();
			 if ((hourNow == hour) && 
			     (minuteNow == minute) && 
				  (secondNow == second) &&
				  (ampmNow.compareTo(ampm)==0)
				 )
				  this.beep();
	}		 
          
}

	
} // end class AlarmClock
