Ejemplo n.º 1
0
        public int Difference(Structures.Time t1, Structures.Time t2)
        {
            Specification(ref t1);
            Specification(ref t2);
            int time1 = TimeSinceMidnight(t1);
            int time2 = TimeSinceMidnight(t2);

            return(time1 - time2);
        }
Ejemplo n.º 2
0
 public void Specification(ref Structures.Time t)
 {
     if (t.s >= 60)
     {
         int temp = (int)Math.Floor((decimal)t.s / 60);
         t.s -= 60 * temp;
         t.m += temp;
     }
     if (t.m >= 60)
     {
         int temp = (int)Math.Floor((decimal)t.m / 60);
         t.m -= 60 * temp;
         t.h += temp;
     }
     if (t.h >= 24)
     {
         int temp = (int)Math.Floor((decimal)t.h / 24);
         t.h -= 24 * temp;
     }
 }
Ejemplo n.º 3
0
        public void processTask1()
        {
            Input input    = new Input();
            ITime computer = new TimeComputer();

            Console.WriteLine("Print some data to run this task(2 times and 2 natural val (seconds and time in second)):");
            Structures.Time time1 = input.inputTime();
            Structures.Time time2 = input.inputTime();
            int             s     = input.inputNaturalInt();
            int             t     = input.inputNaturalInt();

            Console.WriteLine("TimeSinceMidnight realise 1: {0}", computer.TimeSinceMidnight(time1));
            Console.WriteLine("TimeSinceMidnight realise 2: {0}", computer.TimeSinceMidnight(t));
            Console.WriteLine("AddOneSecond realise: {0}", computer.AddOneSecond(time1));
            Console.WriteLine("AddOneMinute realise: {0}", computer.AddOneMinute(time1));
            Console.WriteLine("AddOneHour realise: {0}", computer.AddOneHour(time1));
            Console.WriteLine("AddSeconds realise: {0}", computer.AddSeconds(time1, s));
            Console.WriteLine("Difference realise: {0}", computer.Difference(time1, time2));
            Console.WriteLine("AddOneHour realise: {0}", computer.WhatLesson(time1));

            Console.WriteLine(new string('=', 35));
        }
Ejemplo n.º 4
0
        public string WhatLesson(Structures.Time t)
        {
            Specification(ref t);
            int time = TimeSinceMidnight(t);

            if (time < 8 * 3600)
            {
                return("Пари не розпочалися");
            }

            else if (time >= 8 * 3600 && time < 9 * 3600 + 20 * 60)
            {
                return("1 пара");
            }

            else if (time >= 9 * 3600 + 20 * 60 && time < 9 * 3600 + 40 * 60)
            {
                return("Перерва між 1-ою і 2-ою парою");
            }

            else if (time >= 9 * 3600 + 40 * 60 && time < 11 * 3600)
            {
                return("2 пара");
            }

            else if (time >= 11 * 3600 && time < 11 * 3600 + 20 * 60)
            {
                return("Перерва між 2-ою і 3-ою парою");
            }

            else if (time >= 11 * 3600 + 20 * 60 && time < 12 * 3600 + 40 * 60)
            {
                return("3 пара");
            }

            else if (time >= 12 * 3600 + 40 * 60 && time < 13 * 3600)
            {
                return("Перерва між 3-ою і 4-ою парою");
            }

            else if (time >= 13 * 3600 && time < 14 * 3600 + 20 * 60)
            {
                return("4 пара");
            }

            else if (time >= 14 * 3600 + 20 * 60 && time < 14 * 3600 + 40 * 60)
            {
                return("Перерва між 4-ою і 5-ою парою");
            }

            else if (time >= 14 * 3600 + 40 * 60 && time < 16 * 3600)
            {
                return("5 пара");
            }

            else if (time >= 16 * 3600 && time < 16 * 3600 + 20 * 60)
            {
                return("Перерва між 5-ою і 6-ою парою");
            }

            else if (time >= 16 * 3600 + 20 * 60 && time < 17 * 3600 + 40 * 60)
            {
                return("6 пара");
            }

            else if (time >= 17 * 3600 + 40 * 60)
            {
                return("Пари Скінчились");
            }

            return(time.ToString());
        }
Ejemplo n.º 5
0
 public Structures.Time AddSeconds(Structures.Time t, int s)
 {
     t.s += s;
     Specification(ref t);
     return(t);
 }
Ejemplo n.º 6
0
 public Structures.Time AddOneHour(Structures.Time t)
 {
     t.h += 1;
     Specification(ref t);
     return(t);
 }
Ejemplo n.º 7
0
 public Structures.Time AddOneMinute(Structures.Time t)
 {
     t.m += 1;
     Specification(ref t);
     return(t);
 }
Ejemplo n.º 8
0
 public Structures.Time AddOneSecond(Structures.Time t)
 {
     t.s += 1;
     Specification(ref t);
     return(t);
 }
Ejemplo n.º 9
0
 public int TimeSinceMidnight(Structures.Time t)
 {
     Specification(ref t);
     return(t.h * 3600 + t.m * 60 + t.s);
 }