Esempio n. 1
0
        public static void Alarming(AlarmClock sender)
        {
            ClockTime time = sender.CurrentTime;

            Console.WriteLine($"Alarm Event: {time.Hour}:{time.Minute}:{time.Second}");
            Console.WriteLine("dingling dingling dingling");
        }
Esempio n. 2
0
        private static void ShowTime(AlarmClock sender)
        {
            ClockTime time = sender.CurrentTime;

            Console.WriteLine($"Tick Event: " +
                              $"{time.Hour}:{time.Minute}:{time.Second}");
        }
Esempio n. 3
0
 /// start a clock, and keep it run
 public void Run()
 {
     while (true)
     {
         DateTime now = DateTime.Now;
         CurrentTime = new ClockTime(now.Hour, now.Minute, now.Second);
         TickEvent(this);
         if (AlarmTime.Equals(CurrentTime))
         {
             AlarmEvent(this);
         }
         Thread.Sleep(1000);
     }
 }
Esempio n. 4
0
 public AlarmClock()
 {
     CurrentTime = new ClockTime();
 }