Example #1
0
 public void RemoveAlarmTime(MyTime time)
 {
     if (alarmTimes.Contains(time))
     {
         alarmTimes.Remove(time);
     }
 }
Example #2
0
 public void AddAlarmTime(MyTime time)
 {
     if (!alarmTimes.Contains(time))
     {
         alarmTimes.Add(time);
     }
 }
Example #3
0
 public void Alarming(MyTime time, int seconds)
 {
     Console.WriteLine($"Alarm time -- {time.Hour}:{time.Minute}:{time.Second}");
     Console.WriteLine($"Contiue {seconds} seconds");
     while (seconds-- > 0)
     {
         Console.WriteLine("dingling dingling dingling dingling dingling\a");
         Thread.Sleep(1000);
     }
 }
Example #4
0
 public void Run()
 {
     while (true)
     {
         DateTime now = DateTime.Now;
         currentTime = new MyTime(now.Hour, now.Minute, now.Second);
         if (alarmTimes.Contains(currentTime))
         {
             AlarmEvent(currentTime, 10);
         }
         Thread.Sleep(1000);
     }
 }
Example #5
0
 public MyClock()
 {
     currentTime = new MyTime();
 }