Ejemplo 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");
        }
Ejemplo n.º 2
0
        private static void ShowTime(AlarmClock sender)
        {
            ClockTime time = sender.CurrentTime;

            Console.WriteLine($"Tick Event: " +
                              $"{time.Hour}:{time.Minute}:{time.Second}");
        }
Ejemplo 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);
     }
 }
Ejemplo n.º 4
0
 public AlarmClock()
 {
     CurrentTime = new ClockTime();
 }