private static void ShowTime(MyClock sender) { MyTime time = sender.CurrentTime; Console.WriteLine($"Tick Event: " + $"{time.Hour}:{time.Minute}:{time.Second}"); }
/// /// <summary> /// remove alarm time from clock /// </summary> public void RemoveAlarmTime(int hour, int minute, int second) { MyTime time = new MyTime(hour, minute, second); if (times.ContainsKey(time.Id)) { times.Remove(time.Id); } }
/// <summary> /// response function /// </summary> /// <param name="time">time when the Alarming call</param> /// <param name="seconds">how many seconds the alarming continues</param> 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); } }
public static void Alarming(MyClock sender) { MyTime time = sender.CurrentTime; Console.WriteLine($"Alarm Event: {time.Hour}:{time.Minute}:{time.Second}"); for (int i = 0; i < 10; i++) { Console.WriteLine("dingling dingling dingling"); Thread.Sleep(1000); } }
public void Run() { while (true) { DateTime now = DateTime.Now; CurrentTime = new MyTime(now.Hour, now.Minute, now.Second); TickEvent(this); if (AlarmTime.Equals(CurrentTime)) { AlarmEvent(this); } Thread.Sleep(1000); } }
/// <summary> /// constuctor /// </summary> public MyClock() { currentTime = new MyTime(); times = new Dictionary <int, int>(); }
public MyClock() { CurrentTime = new MyTime(); }