Exemple #1
0
        /*
         * public static Calc_kalendar operator +(Calc_kalendar k1, int data)
         * {
         *  int d = 0;
         *  d = k1.dday + data;
         *  int m = 0;
         *  if (d > 31)
         *  {
         *      k1.month+= d / 31;
         *      k1.dday = d % 31;
         *
         *      if (k1.month > 12)
         *      {
         *          m = k1.month % 12;
         *          k1.year += m;
         *          k1.month = k1.month % 12;
         *      }
         *
         *  }
         *  else
         *  {
         *      k1.dday = d;
         *  }
         *
         *
         *  return k1;
         * }
         */

        public static Calc_kalendar operator +(Calc_kalendar k1, int data)
        {
            try
            {
                MyExc ex = new MyExc();
                while (true)
                {
                    if (data > 0 && data < 31)
                    {
                        k1.dday += data;
                        if (k1.dday > 31)
                        {
                            k1.month++;
                            k1.dday = k1.dday - 31;
                        }
                        break;
                    }

                    else
                    {
                        Console.WriteLine("Error enter!");
                        break;
                    }
                }
            }
            catch (MyExc ex)
            {
                if (data <= 0 || data > 31)
                {
                    Console.WriteLine(ex.Message);
                    data = Convert.ToInt32(Console.ReadLine());
                }
            }
            return(k1);
        }
Exemple #2
0
 public void exc()
 {
     try
     {
         MyExc ex = new MyExc();
         ReadFromConsole();
         while (true)
         {
             if (dday <= 0 || dday > 31)
             {
                 Console.WriteLine("ERROR! Poprobuyte yeshche raz vvesti den: ");
             }
             else
             {
                 break;
             }
             if (month <= 0 || month > 12)
             {
                 Console.WriteLine("ERROR! Poprobuyte yeshche raz vvesti month: ");
             }
             else
             {
                 break;
             }
         }
     }
     catch (MyExc ex)
     {
         if (dday <= 0 || dday > 31)
         {
             Console.WriteLine(ex.Message);
             ReadFromConsole();
         }
         if (month <= 0 || month > 12)
         {
             Console.WriteLine(ex.Message);
             ReadFromConsole();
         }
     }
 }