public void HaveIntersectionTest() { var time1 = new Time.Time(10, 20); var time2 = new Time.Time(11, 20); var time3 = new Time.Time(10, 30); var time4 = new Time.Time(9, 20); var time5 = new Time.Time(12, 20); var interval1 = new Interval(time1, time2); var interval2 = new Interval(time3, time2); var interval3 = new Interval(time2, time5); var interval4 = new Interval(time4, time1); var interval5 = new Interval(time4, time4); Assert.AreEqual(interval1.HaveIntersection(interval2), true); Assert.AreEqual(interval1.HaveIntersection(interval3), true); Assert.AreEqual(interval1.HaveIntersection(interval4), true); Assert.AreEqual(interval1.HaveIntersection(interval5), false); Assert.AreEqual(interval1.HaveIntersection(interval2, false), true); Assert.AreEqual(interval1.HaveIntersection(interval3, false), false); Assert.AreEqual(interval1.HaveIntersection(interval4, false), false); Assert.AreEqual(interval1.HaveIntersection(interval5, false), false); }
private void SetBulbs(Time.Time time) { var numberOfBulbsToTurnOn = time.Hours / _hoursPassedToLightUpBulb; for (int i = 0; i < numberOfBulbsToTurnOn; i++) { _bulbs[i].TurnOn(); } }
private void SetBulbs(Time.Time time) { var bulbsToLightUp = time.Minutes % _minutesPassedBetweenEachBulb; for (int i = 0; i < bulbsToLightUp; i++) { _bulbs[i].TurnOn(); } }
/// <inheritdoc /> public void LightUp(Time.Time time) { _notOddSecondsElapsedBulb.TurnOff(); if ((time.TotalElapsedSeconds % 2) == 0) { _notOddSecondsElapsedBulb.TurnOn(); } }
private bool MakeVarsTime() { if (h1.Text == "" || h2.Text == "" || s1.Text == "" || s2.Text == "" || m1.Text == "" || m2.Text == "") { MessageBox.Show("Некорректные значения"); return(false); } try { if (t1 is null || t2 is null) { t1 = new Time.Time(Convert.ToSByte(h1.Text), Convert.ToSByte(m1.Text), Convert.ToSByte(s1.Text)); t2 = new Time.Time(Convert.ToSByte(h2.Text), Convert.ToSByte(m2.Text), Convert.ToSByte(s2.Text)); } if (h1.Text != t1.Hour.ToString()) { t1.Hour = Convert.ToSByte(h1.Text); } if (m1.Text != t1.Minute.ToString()) { t1.Minute = Convert.ToSByte(m1.Text); } if (s1.Text != t1.Second.ToString()) { t1.Second = Convert.ToSByte(s1.Text); } if (h2.Text != t2.Hour.ToString()) { t2.Hour = Convert.ToSByte(h2.Text); } if (m2.Text != t2.Minute.ToString()) { t2.Minute = Convert.ToSByte(m2.Text); } if (s2.Text != t2.Second.ToString()) { t2.Second = Convert.ToSByte(s2.Text); } h1.Text = t1.Hour.ToString(); h2.Text = t2.Hour.ToString(); m2.Text = t2.Minute.ToString(); m1.Text = t1.Minute.ToString(); s1.Text = t1.Second.ToString(); s2.Text = t2.Second.ToString(); } catch { MessageBox.Show("Некорректные значения"); return(false); } return(true); }
/// <summary> /// Implements <see cref="IExtractor.ExtractTimed{T}" /> /// </summary> public Tuple <IList <T>, TimeSpan> ExtractTimed <T>(IList <string> extractionAssemblies) where T : INode { var time = new Time.Time(); time.Start(); var extractResult = Extract <T>(extractionAssemblies); time.Stop(); return(new Tuple <IList <T>, TimeSpan>(extractResult, time.Elapsed)); }
static void Main(string[] args) { var time = new Time.Time(); var database = new Common.Database(); var securityGateway = new Security.Gateway.Gateway(time, database); var router = Factory.CreateRouter(); router = securityGateway.RoutesUp(router); Http.Server.HttpServer.Start("http://*:8888/", router); }
//Методы выбора слов из набора /// <summary> /// Метод для выбора слов из набора "Приветствия" /// </summary> public static string Greeting() { if (GreetingWords == null) { GreetingWords = new List <string> { "доброе утро", "добрый день", "доброй ночи", "добрый вечер", "добрейший вечерочек", "вечер в чат", "здравтсвуйте", "привет", "доброго времени суток", "hello", "невероятно рад тебя слышать", "здравствуй", "хай", "какая встреча", "не здоровоюсь", "рад приветствовать" } } ; //Приветствовать с учетом времени суток if (ToChoose.Next(0, 5) == 0) { Time.Time now = Time.Time.Now; if (now.Hour >= 21 || now.Hour <= 3) { return(GreetingWords[2]); // Ночь } if (now.Hour >= 4 && now.Hour <= 12) { return(GreetingWords[0]); //Утро } if (now.Hour >= 13 && now.Hour <= 18) { return(GreetingWords[1]); //День } if (now.Hour >= 18) { return(GreetingWords[ToChoose.Next(3, 5)]); //Вечер } } Index = ToChoose.Next(6, GreetingWords.Count); if (Index == GreetingWords.Count - 1) { return(GreetingWords[Index] + " " + Who()); } return(GreetingWords[Index]); }
public void TestTimeSort() { const int testLen = 500; var testArr = new Time.Time[testLen]; var r = new Random(RandomSeed); for (var i = 0; i < testLen; i++) { var time = new StartTime(r.Next(0, 10000)); testArr[i] = time; } Array.Sort(testArr); for (var i = 0; i < testLen - 1; i++) { Assert.True(testArr[i].TimeStamp <= testArr[i + 1].TimeStamp); Assert.True(testArr[i].CompareTo(testArr[i + 1]) <= 0); Assert.True(testArr[i + 1].CompareTo(testArr[i]) >= 0); } }
public void IsInIntervalTest() { var time1 = new Time.Time(10, 20); var time2 = new Time.Time(11, 20); var time3 = new Time.Time(10, 30); var time4 = new Time.Time(9, 20); var time5 = new Time.Time(12, 20); var interval = new Interval(time1, time2); Assert.AreEqual(interval.IsInInterval(time1), true); Assert.AreEqual(interval.IsInInterval(time2), true); Assert.AreEqual(interval.IsInInterval(time3), true); Assert.AreEqual(interval.IsInInterval(time4), false); Assert.AreEqual(interval.IsInInterval(time5), false); Assert.AreEqual(interval.IsInInterval(time1, false), false); Assert.AreEqual(interval.IsInInterval(time2, false), false); Assert.AreEqual(interval.IsInInterval(time3, false), true); Assert.AreEqual(interval.IsInInterval(time4, false), false); Assert.AreEqual(interval.IsInInterval(time5, false), false); }
/// <inheritdoc /> public void LightUp(Time.Time time) { Reset(); SetBulbs(time); }
/// <summary> /// Initializes a new instance of the <see cref="TimeIq"/> class. /// </summary> public TimeIq() { GenerateId(); Time = new Time.Time(); }
public void SetTime(Time.Time time) { _currentTime = time; LightUpBulbs(); }
public AlarmClockEventArgs(Time.Time time) { Time = time; }