Example #1
0
        public static Int32 TransformNumber(Int32 x)
        {
            Int32 transformedNumber = x;

            try
            {
                if (x > 0)
                {
                    checked
                    {
                        transformedNumber *= 7;
                    }
                    Console.WriteLine(
                        $"Число {x} положительное, и после трансформации оно станет: {transformedNumber}");
                }
                else if (x < 0)
                {
                    transformedNumber += 7;
                    Console.WriteLine(
                        $"Число {x} отрицательное, и после трансформации оно станет: {transformedNumber}");
                }
                else
                {
                    Console.WriteLine(transformedNumber);
                }
            }
            catch (OverflowException e)
            {
                CustomLogger.LogException(e);
                throw;
            }

            return(transformedNumber);
        }
Example #2
0
 public void Run()
 {
     try
     {
         SRaceIO.StartMenu();
     }
     catch (Exception e)
     {
         CustomLogger.LogException(e);
         throw;
     }
 }
Example #3
0
        public void Run()
        {
            Int32 x;

            Console.Write("Введите число: ");
            try
            {
                x = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine($"Квадрат числа: {x * x}");
            }
            catch (Exception e)
            {
                CustomLogger.LogException(e);
            }
        }
Example #4
0
        public void Run()
        {
            Int32 x, y, z;

            try
            {
                Console.Write("Введите 1-е число: ");
                x = Convert.ToInt32(Console.ReadLine());
                Console.Write("Введите 2-е число: ");
                y = Convert.ToInt32(Console.ReadLine());
                Console.Write("Введите 3-е число: ");
                z = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine($"{x} + {y} + {z} = {x + y + z}");
            }
            catch (Exception e)
            {
                CustomLogger.LogException(e);
            }
        }
Example #5
0
        public static Int32 MinToSec(Int32 min)
        {
            try
            {
                Int32 res;

                checked
                {
                    res = min * 60;
                }

                return(res);
            }
            catch (Exception e)
            {
                CustomLogger.LogException(e);
            }

            return(-1);
        }
Example #6
0
        public static Int32 Sum(params Int32[] numbers)
        {
            Int32 sum = 0;

            try
            {
                for (Int32 i = 0; i < numbers.Length; i++)
                {
                    checked
                    {
                        sum += numbers[i];
                    }
                }
            }
            catch (OverflowException e)
            {
                CustomLogger.LogException(e);
                throw;
            }

            return(sum);
        }