public void RemoveAlarmTime(MyTime time) { if (alarmTimes.Contains(time)) { alarmTimes.Remove(time); } }
public void AddAlarmTime(MyTime time) { if (!alarmTimes.Contains(time)) { alarmTimes.Add(time); } }
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 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); } }
public MyClock() { currentTime = new MyTime(); }