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"); }
private static void ShowTime(AlarmClock sender) { ClockTime time = sender.CurrentTime; Console.WriteLine($"Tick Event: " + $"{time.Hour}:{time.Minute}:{time.Second}"); }
/// 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); } }
public AlarmClock() { CurrentTime = new ClockTime(); }