Пример #1
0
        static void Main(string[] args)
        {
            double[] mass = Array(args);
            var      calc = new Core.Calc();

            switch (args[0])
            {
            case "sum":
                Console.WriteLine(calc.Sum(mass));
                break;

            case "sub":
                Console.WriteLine(calc.Sub(mass));
                break;

            case "pow":
                Console.WriteLine(calc.Pow(mass));
                break;

            case "multi":
                Console.WriteLine(calc.Multi(mass));
                break;

            default:
                Console.WriteLine("Что-то пошло не так");
                break;
            }
            Console.Read();
        }
Пример #2
0
        public void TestSub()
        {
            var calc = new Core.Calc();
            var sub  = 1;

            var result = calc.Sub(new[] { 6, 3, 2 });

            Assert.AreEqual(sub, result);
        }
Пример #3
0
        public void TestSub()
        {
            var calc = new Core.Calc();
            var sub  = 10;

            var result = calc.Sub(new[] { 100, 80, 10 });

            Assert.AreEqual(sub, result);
        }
Пример #4
0
        public void TestSub()
        {
            //Arrange
            var calc = new Core.Calc();
            var Sub  = 10;
            //act
            var result = calc.Sub(new[] { 13.0, 1.0, 2.0 });

            //Assent
            Assert.AreEqual(Sub, result);
        }
Пример #5
0
        public void TestSub()
        {
            // arrange
            var calc = new Core.Calc();
            var sub  = -12;

            // act
            var result = calc.Sub(new[] { 5, 3, 14 });

            // assert
            Assert.AreEqual(sub, result);
        }
Пример #6
0
        static void Main(string[] args)
        {
            try
            {
                Core.Calc calc = new Core.Calc();
                Console.WriteLine("Введите одну из операций: sum, sub, pow.\nПриемер: sum 5 3 2");
                string[] input = Console.ReadLine().Split(' ');
                cmds     cm;
                if (!Enum.TryParse(input[0], out cm))
                {
                    throw new Exception("Некорректный ввод");
                }
                int[] arr = input.Skip(1).Select(x =>
                {
                    int r;
                    if (int.TryParse(x.ToString(), out r))
                    {
                        return(r);
                    }
                    else
                    {
                        throw new Exception("Некорректный ввод");
                    }
                }).ToArray();
                long res = 0;
                switch (cm)
                {
                case cmds.sum:
                    res = calc.Sum(arr);
                    break;

                case cmds.sub:
                    res = calc.Sub(arr);
                    break;

                case cmds.pow:
                    res = calc.Pow(arr);
                    break;
                }

                Console.WriteLine(res);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Console.ReadKey();
            }
        }