Esempio n. 1
0
        public void SwapArrayPartsTest(int[] arr, int[] expected)
        {
            Homework_2 hw2 = new Homework_2();

            int[] actual = hw2.SwapArrayParts(arr);
            Assert.AreEqual(expected, actual);
        }
Esempio n. 2
0
        public void FindMinInArray_arrTest(int[] arr, int[] expected)
        {
            Homework_2 hw2 = new Homework_2();

            int[] actual = hw2.FindMinInArray(arr);
            Assert.AreEqual(expected, actual);
        }
Esempio n. 3
0
        public void ReverseArrayTest(int[] arr, int[] expected)
        {
            Homework_2 hw2 = new Homework_2();

            int[] actual = hw2.ReverseArray(arr);
            Assert.AreEqual(expected, actual);
        }
Esempio n. 4
0
        public void SubstituteSignеTest(float a, float b, char sign, float expected)
        {
            Homework_2 hw2    = new Homework_2();
            float      actual = hw2.SubstituteSign(a, b, sign);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 5
0
        public void FibonacciOfNumberTest(int n, int[] expected)
        {
            Homework_2 hw2 = new Homework_2();

            int[] actual = hw2.FibonacciOfNumber(n);
            Assert.AreEqual(expected, actual);
        }
Esempio n. 6
0
        public void GetNumbLessAvTest(int[] arr, int[] expected)
        {
            Homework_2 hw2 = new Homework_2();

            int[] actual = hw2.GetNumbLessAv(arr, 35);
            Assert.AreEqual(expected, actual);
        }
Esempio n. 7
0
        public void CalcArithmeticalMeanTest(int[] arr, int expected)
        {
            Homework_2 hw2 = new Homework_2();

            int actual = hw2.CalcArithmeticalMean(arr);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 8
0
        public void FlipNumberBackwardsTest(int n, int expected)
        {
            Homework_2 hw2 = new Homework_2();

            int actual = hw2.FlipNumberBackwards(n);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 9
0
        public void CalcPercentageTest(int count, int amount, double expected)
        {
            Homework_2 hw2 = new Homework_2();

            double actual = hw2.CalcPercentage(count, amount);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 10
0
        public void CheckEqualityTest(int number, int guess, string expected)
        {
            Homework_2 hw2 = new Homework_2();

            string actual = hw2.CheckEquality(number, guess);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 11
0
        public void GetSumBetweenMinMaxTest(int[] arr, int minResultIndex, int maxResultIndex, int expected)
        {
            Homework_2 hw2 = new Homework_2();

            int actual = hw2.GetSumBetweenMinMax(arr, minResultIndex, maxResultIndex);

            Assert.AreEqual(expected, actual);
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            int sw = int.MinValue;

            Console.WriteLine("Hello, it is a homework №2\nPlease choose operation you want to do\n");

            while (sw != 3)
            {
                Console.WriteLine("1. Task 1\n" +
                                  "2. Task 2\n" +
                                  "3. Exit program\n\n" +
                                  "Your choice: ");
                do
                {
                    sw = Homework_2.ReadFromConsole();
                    if (sw == 1 || sw == 2 || sw == 3)
                    {
                        break;
                    }
                    else
                    {
                        Console.WriteLine("Incorrect input! Try again\n");
                    }
                } while (true);

                switch (sw)
                {
                case 1:
                    Console.Write("Please input start value: ");
                    int first = Homework_2.ReadFromConsole();

                    Console.Write("Please input last value: ");
                    int last = Homework_2.ReadFromConsole();

                    Console.Write("Please input first multiplier: ");
                    int mul_1;
                    do
                    {
                        mul_1 = Homework_2.ReadFromConsole();

                        if (!Homework_2.IsPrimeNumber(mul_1))
                        {
                            Console.WriteLine("Please input prime number: ");
                        }
                        else
                        {
                            break;
                        }
                    } while (true);

                    Console.Write("Please input second multiplier: ");
                    int mul_2;
                    do
                    {
                        mul_2 = Homework_2.ReadFromConsole();

                        if (!Homework_2.IsPrimeNumber(mul_2))
                        {
                            Console.WriteLine("Please input prime number: ");
                        }
                        else
                        {
                            break;
                        }
                    } while (true);

                    Homework_2.FizzBuzz(first, last, mul_1, mul_2);
                    Console.WriteLine("Do you want to continue?\n");
                    break;

                case 2:
                    Console.WriteLine("Please input distance: ");

                    double x = double.MaxValue;
                    do
                    {
                        x = Homework_2.ReadFromConsole(x);
                        if (x < 0)
                        {
                            Console.WriteLine("Incorrect input! Try again\n");
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    } while (true);
                    Console.WriteLine("Please input increase of distance by every day: ");

                    double y = default(double);
                    do
                    {
                        y = Homework_2.ReadFromConsole(y);
                        if (y < 0)
                        {
                            Console.WriteLine("Incorrect input! Try again\n");
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    } while (true);

                    Console.WriteLine("Please input distance is needed to reech");

                    double z = default(double);
                    do
                    {
                        z = Homework_2.ReadFromConsole(z);
                        if (z < 0 || z < x)
                        {
                            Console.WriteLine("Incorrect input! Try again\n");
                            continue;
                        }
                        else
                        {
                            break;
                        }
                    } while (true);

                    Homework_2.Task_2(x, y, z);

                    Console.WriteLine("Do you want to continue?\n");
                    break;

                case 3:
                    break;
                }
            }
            Console.ReadKey();
        }