Пример #1
0
        public string WhatLesson(MyTime mt)
        {
            string messageOne = "пари не почались.";
            string messageTwo = "Пари закінчились.";

            int[] breaksLength = { 20, 20, 20, 20, 10, 10, 0 };

            MyTime startTime = new MyTime(8, 0, 0);

            //14:20:10
            if (Difference(mt, startTime) <= 0)
            {
                return(messageOne);
            }
            for (int lessonNum = 0; lessonNum < breaksLength.Length; lessonNum++)
            {
                startTime = AddSeconds(startTime, 80 * 60);
                if (Difference(mt, startTime) < 0)
                {
                    return(string.Format($"{lessonNum + 1} - а пара."));
                }
                startTime = AddSeconds(startTime, breaksLength[lessonNum] * 60);
                if (lessonNum == breaksLength.Length - 1)
                {
                    break;
                }
                if (Difference(mt, startTime) <= 0)
                {
                    return(string.Format($"Перерва між {lessonNum + 1}-ю та {lessonNum + 2}-ю парами"));
                }
            }

            return(messageTwo);
        }
Пример #2
0
        static void Main(string[] args)
        {
            bool isOpen = true;

            MyTime myTime = new MyTime();

            while (isOpen)
            {
                Console.Write("Введіть години: ");
                myTime.Hour = int.Parse(Console.ReadLine());
                Console.Write("Введіть хвилини: ");
                myTime.Minute = int.Parse(Console.ReadLine());
                Console.Write("Введіть секунди: ");
                myTime.Second = int.Parse(Console.ReadLine());

                Console.WriteLine($"{myTime} - {myTime.WhatLesson(myTime)}");

                Console.ReadKey();
                Console.Clear();
            }
        }
Пример #3
0
 public int Difference(MyTime mt1, MyTime mt2)
 {
     return(TimeSinceMidnight(mt1) - TimeSinceMidnight(mt2));
 }
Пример #4
0
 public MyTime AddSeconds(MyTime t, int s)
 {
     return(TimeSinceMidnight(TimeSinceMidnight(t) + s));
 }
Пример #5
0
 public MyTime AddOneHour(MyTime t)
 {
     return(TimeSinceMidnight(TimeSinceMidnight(t) + 3600));
 }
Пример #6
0
 public MyTime AddOneMinute(MyTime t)
 {
     return(TimeSinceMidnight(TimeSinceMidnight(t) + 60));
 }
Пример #7
0
 public MyTime AddOneSecond(MyTime t)
 {
     return(TimeSinceMidnight(TimeSinceMidnight(t) + 1));
 }
Пример #8
0
 public int TimeSinceMidnight(MyTime t)
 {
     return(t.Hour * 3600 + t.Minute * 60 + t.Second);
 }