Пример #1
0
        public void FilterDigit_8()
        {
            var collection = new int[] { 8, 81, 67582, 53, 81, 2324, 8, 3335, 81, 86 };
            var expected   = new int[] { 8, 81, 67582, 86 };

            var actual = Task4.FilterDigit(collection, 8).ToArray();

            CollectionAssert.AreEqual(expected, actual);
        }
Пример #2
0
        public void FilterDigit_IsNegativeDigit_ArgumentException()
        {
            // Arrange
            IEnumerable <int> source = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 68, 69, 70, 15, 17
            };
            int digit = -8;

            // Assert
            Assert.Throws <ArgumentException>(() => Task4.FilterDigits(source, digit));
        }
Пример #3
0
        public void TestSample1()
        {
            Task4  p              = new Task4(); //creating an object instance
            string output         = p.DrawStarTriangle(3);
            string expectedOutput =
                "[*]\n" +
                "[*][*]\n" +
                "[*][*][*]\n";

            Assert.AreEqual(expectedOutput, output);
        }
Пример #4
0
        public void FindIndexOFMaxTest(int MockNumber, int expectedI, int expectedJ)
        {
            int[,] array = DoubleArrayMockTask4.GetMock(MockNumber);
            int[] actual = Task4.FindIndexOFMax(array);

            int actualI = actual[0];
            int actualJ = actual[1];

            Assert.AreEqual(expectedI, actualI);
            Assert.AreEqual(expectedJ, actualJ);
        }
Пример #5
0
        public void FilterDigit_ReturnedEmptySequence()
        {
            // Arrange
            IEnumerable <int> source = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 68, 70, 15, 17
            };
            int digit = 9;
            // Act
            IEnumerable <int> result = Task4.FilterDigits(source, digit);

            // Assert
            Assert.IsTrue(result.Count() == 0);
        }
Пример #6
0
 /// <summary>
 /// The main.
 /// </summary>
 /// <param name="args">
 /// The args.
 /// </param>
 private static void Main(string[] args)
 {
     Task1.Execute();
     Task2.Execute();
     Task3.Execute();
     Task4.Execute();
     Task5.Execute();
     Task6.Execute();
     Task7.Execute();
     Task8.Execute();
     Task9.Execute();
     Task10.Execute();
 }
        public void FilterDigitTest_InputListOfNumber1_3_7_55_4_15_56_253_33WithDigit8_ExpectedEmpty()
        {
            Task4      task4 = new Task4();
            List <int> list  = new List <int> {
                1, 3, 7, 55, 4, 15, 56, 253, 33
            };
            int        digit    = 8;
            List <int> expected = new List <int>();
            List <int> actual   = task4.FilterDigit(list, digit);

            // Assert.AreEqual(actual.Count,expected.Count);
            Assert.IsTrue(actual.SequenceEqual(expected));
        }
Пример #8
0
        public void FilterDigit_InputCorrectValues()
        {
            //Arrange
            int currentDigit = 5;
            List<int> inputList = new List<int> { 1, 2, 5, 7, 3, 334, 566, 223, 66, 334, 54, 95, 8 };
            List<int> expected = new List<int> { 5, 566, 54, 95 };

            //Act
            List<int> result = Task4.FilterDigit(inputList, currentDigit);

            //Assert
            Assert.IsTrue(expected.SequenceEqual(result));
        }
        static void Main(string[] args)
        {
            Func <Task4, char[, ]> TaskSolver = task =>
            {
                // Your solution goes here
                // You can get all needed inputs from task.[Property]
                // Good luck!
                char[,] board = task.Board;

                int x = board.GetLength(0);
                int y = board.GetLength(1);
                char[,] virtualBoard = new char[x + 2, y + 2];

                for (int i = 1; i <= y; i++)
                {
                    for (int j = 1; j <= x; j++)
                    {
                        virtualBoard[j, i] = board[j - 1, i - 1];
                    }
                }

                char[,] answerBoard = new char[x, y];

                for (int i = 1; i <= y; i++)
                {
                    for (int j = 1; j <= x; j++)
                    {
                        int aliveCells = GetAliveCellsCount(j, i, virtualBoard);

                        if (virtualBoard[j, i] == '1' &&
                            (aliveCells == 2 || aliveCells == 3))
                        {
                            answerBoard[j - 1, i - 1] = '1';
                        }
                        else if (virtualBoard[j, i] == '0' &&
                                 aliveCells == 3)
                        {
                            answerBoard[j - 1, i - 1] = '1';
                        }
                        else
                        {
                            answerBoard[j - 1, i - 1] = '0';
                        }
                    }
                }

                return(answerBoard);
            };

            Task4.CheckSolver(TaskSolver);
        }
Пример #10
0
        static void Main(string[] args)
        {
            Func <Task4, char[, ]> TaskSolver = task =>
            {
                // Your solution goes here
                // You can get all needed inputs from task.[Property]
                // Good luck!
                char[,] board = task.Board;

                return(board);
            };

            Task4.CheckSolver(TaskSolver);
        }
Пример #11
0
        public void SolveSquareEquationTests(double a, double b, double c, double[] expected)
        {
            double[] actual = Task4.SolveSquareEquation(a, b, c);
            double   delta  = 0.01;

            if (expected.Length != actual.Length)
            {
                Assert.Fail();
            }

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i], delta);
            }
        }
Пример #12
0
        private void Reshenie_Click(object sender, EventArgs e)
        {
            int[,] arr = Arr();
            Task4 task4 = new Task4();
            int   ret   = task4.Prohod(0, 0, arr, arr.GetLength(0), arr.GetLength(1));

            Zap_dgv(arr);
            if (ret == 10)
            {
                MessageBox.Show("Bingo");
            }
            else if (ret == 11)
            {
                MessageBox.Show("Fail");
            }
        }
Пример #13
0
        public void FilterDigistTestOne()
        {
            Task4      item    = new Task4();
            List <int> numbers = new List <int>()
            {
                14, 51, 72, 4, 88, 11, 41, 7, 1482
            };
            List <int> expectedResult = new List <int>()
            {
                14, 4, 41, 1482
            };
            int        numberByCompare = 4;
            List <int> result          = item.FilterDigit(numbers, numberByCompare);

            expectedResult.Any(element => expectedResult.Contains(element));
        }
Пример #14
0
 /// <summary>
 /// The main.
 /// </summary>
 /// <param name="args">
 /// The args.
 /// </param>
 private static void Main(string[] args)
 {
     Task2.ExtractArtists(FileName);
     Task3.ExtractArtistsXPath(FileName);
     Task4.DeleteAllAlbumsWithPriceMoreThan20(FileName);
     Task5.ExtractAllSongTitles(FileName);
     Task6.ExtractAllSongTitlesXpathLinq(FileName);
     Task7.CreateXmlFromTxtFile(TxtName);
     Task8.CreateAlbumXml(FileName);
     Task9.TraverseDirectory("../..");
     Task10.TraverseDirectory("../..");
     Task11.ExtractAlbumPrices(FileName);
     Task12.ExtractAlbumPricesLinq(FileName);
     Task14.ConvertXmlToXsl(FileName, XslName);
     Task16.GenerateXsdFile(FileName);
 }
Пример #15
0
        public void FilterDigit_CorrectValues()
        {
            // Arrange
            IEnumerable <int> source = new List <int> {
                1, 2, 3, 4, 5, 6, 7, 68, 69, 70, 15, 17
            };
            int digit = 7;
            IEnumerable <int> expected = new List <int> {
                7, 70, 17
            };

            // Act
            IEnumerable <int> result = Task4.FilterDigits(source, digit);

            // Assert
            Assert.IsTrue(expected.SequenceEqual(result));
        }
Пример #16
0
        public void Test1()
        {
            var result     = Task4.GetStudentsByBirth();
            var repository = new Repository();

            result = result.OrderBy(i => i.Id).ToList();

            List <int> matchIds = new List <int>()
            {
                1, 12
            };

            if (matchIds.Except(result.Select(i => i.Id)).Any() || result.Select(i => i.Id).Except(matchIds).Any())
            {
                Assert.Fail();
            }
        }
Пример #17
0
        static void Main(string[] args)
        {
            while (true)
            {
                IOservice.ShowMessage
                (
                    "1 - TaskOne (conversion from grams)\n" +
                    "2 - TaskTwo (converting bytes to kilo, mega, Giga)\n" +
                    "3 - TaskThree (Centimeters to meters and kilometers)\n" +
                    "4 - TaskFour (Swap values of variables without using an additional variable)\n" +
                    "5 - TaskFive (the ratio of the cost of 1 kg of candy to 1 kg of gelatine)\n" +
                    "exit - Exit the program"
                );
                string command = IOservice.GetUserInputStr();
                switch (command)
                {
                case "1":
                    Task1.StartTask();
                    break;

                case "2":
                    Task2.StartTask();
                    break;

                case "3":
                    Task3.StartTask();
                    break;

                case "4":
                    Task4.StartTask();
                    break;

                case "5":
                    Task5.StartTask();
                    break;

                case "exit":
                    return;

                default:
                    IOservice.ShowMessage("Unknown command");
                    break;
                }
            }
        }
Пример #18
0
        public void FilterDigitTest1()
        {
            //arrange
            List <int> testList = new List <int>()
            {
                7, 1, 2, 3, 4, 5, 6, 7, 68, 69, 70, 15, 17
            };
            int        testNumber = 7;
            List <int> expected   = new List <int>()
            {
                7, 70, 17
            };
            //act
            List <int> actual = Task4.FilterDigit(testList, testNumber);

            //assert
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Пример #19
0
        public void TestSingleCase()
        {
            string inputFolder = System.IO.Path.GetTempPath() + System.IO.Path.PathSeparator
                                 + Guid.NewGuid().ToString() + System.IO.Path.PathSeparator + "MyInputFolder";

            string outputFolder = System.IO.Path.GetTempPath() + System.IO.Path.PathSeparator
                                  + Guid.NewGuid().ToString() + System.IO.Path.PathSeparator + "MyOutputFolder";

            string fileName = "demofile.txt";

            Task4 t = new Task4();

            t.createCopyDrop(inputFolder, outputFolder, fileName);
            Assert.IsFalse(File.Exists(inputFolder + Path.PathSeparator + fileName));
            Assert.IsTrue(File.Exists(outputFolder + Path.PathSeparator + fileName));

            File.Delete(outputFolder + Path.PathSeparator + fileName);
        }
Пример #20
0
        public void FilterDigitTest2()
        {
            //arrange
            List <int> testList = new List <int>()
            {
                33, 71, 19, 32, 4, 9, 13, 8, 6, 7, 11, 91, 0
            };
            int        testNumber = 1;
            List <int> expected   = new List <int>()
            {
                71, 19, 13, 11, 91
            };
            //act
            List <int> actual = Task4.FilterDigit(testList, testNumber);

            //assert
            Assert.AreEqual(expected.ToString(), actual.ToString());
        }
Пример #21
0
        static void Main(string[] args)
        {
            AbstractTask App;

            App = new Task1();
            App.Start();

            App = new Task2();
            App.Start();

            App = new Task3();
            App.Start();

            App = new Task4();
            App.Start();

            App = new Task5();
            App.Start();
        }
        static void Main(string[] args)
        {
            Func <Task4, char[, ]> TaskSolver = task =>
            {
                // Your solution goes here
                // You can get all needed inputs from task.[Property]
                // Good luck!
                char[,] board = task.Board;
                int rowNum     = board.GetLength(0);
                int coloumnNum = board.GetLength(1);

                char[,] newBoard = new char[rowNum, coloumnNum];

                NextBoard(board, newBoard);

                return(newBoard);
            };

            Task4.CheckSolver(TaskSolver);
        }
    // Start is called before the first frame update
    void Awake()
    {
        SelectorNode root = new SelectorNode();

        SequenceNode seq1  = new SequenceNode();
        Task1        task1 = new Task1(sc, pl);
        Task2        task2 = new Task2(sc, pl);

        seq1.addChild(task1);
        seq1.addChild(task2);

        SequenceNode seq2  = new SequenceNode();
        Task3        task3 = new Task3(sc, osc);
        Task4        task4 = new Task4(sc, osc);

        seq2.addChild(task3);
        seq2.addChild(task4);

        SelectorNode sel2  = new SelectorNode();
        SequenceNode seq3  = new SequenceNode();
        Task5        task5 = new Task5(sc);
        Task6        task6 = new Task6(sc);

        seq3.addChild(task5);
        seq3.addChild(task6);
        Task7 task7 = new Task7(sc);

        sel2.addChild(seq3);
        sel2.addChild(task7);

        root.addChild(seq1);
        root.addChild(seq2);
        root.addChild(sel2);

        behavior = new BehaviorTree(root);

        sc.SetDestination(sc.transform.position);
    }
        static void Main(string[] args)
        {
            Func <Task4, char[, ]> TaskSolver = task =>
            {
                char[,] initialBoard = task.Board;
                char[,] board        = (char[, ])initialBoard.Clone();

                int height = board.GetLength(1);
                int width  = board.GetLength(0);

                for (int y = 0; y < height; ++y)
                {
                    for (int x = 0; x < width; ++x)
                    {
                        board[x, y] = ProcessCell(x, y, initialBoard);
                    }
                }

                return(board);
            };

            Task4.CheckSolver(TaskSolver);
        }
Пример #25
0
        static void Main(string[] args)
        {
            string someText   = "sometext444is777here";
            string textWithIp = "My IP is 185.219.78.170 !";

            string digits          = someText.ExtractDigits();
            string letters         = someText.ExtractLetters();
            string textAfterSymbol = someText.ExtractTextAfterSymbol("x");
            string ip = textWithIp.ExtractIp();

            FileActions file = new FileActions();

            file.CreateWriteFile(textWithIp);
            string fileText   = file.ReadFromFIle();
            string ipFromFile = fileText.ExtractIp();

            file.DeleteFile();

            Task1 task1 = new Task1();

            task1.AssignDifferentValues();
            task1.DontAssignValues();
            task1.AssignSameValues();
            task1.SameValuesFloadDouble();
            task1.DivideByZero();
            task1.DivideByThree();
            task1.DivideByThreeAndRound();

            Task2 task2 = new Task2();

            task2.CompareBoolAndPrint(); //how to use 'case' here?
            task2.CompareDifferentNumericValues();
            task2.LogicalANDandOR();
            task2.DifferentStrings();

            Task3 task3 = new Task3();

            task3.SimpleCycles();
            task3.TenTimesLoop();
            int factorial = task3.RecursionWithExitCondition(3);
            //task3.InfiniteLoop();
            //task3.RecursionWithoutExitCondition(4);

            Task4 task4 = new Task4();

            task4.MyList();
            task4.MyDictionary();
            task4.MyTuple();

            Task5 task5 = new Task5();

            task5.ListGet();
            task5.ListAdd();
            task5.ListRemove();
            task5.PrintNewList();

            Task6 task6 = new Task6();

            task6.DivideByZero();

            Task7 task7 = new Task7();

            task7.CreateWriteFile();
            task7.MathOperationsOnNumbersFromString();

            Task8_Serialization2 task8 = new Task8_Serialization2();

            task8.Serialize();  //how to serialize a class, not an object? how to print serialized object?

            Task9 task9 = new Task9();

            task9.ParseToJson();

            Task10 task10 = new Task10();

            task10.PrintConcatenatedStrings();
            task10.TrimString();
            task10.PrintWordsInSeparateRow();
            task10.CleanEmptySpaces();
            task10.ToUppercase();
            task10.AllWToUppercase();
            task10.FirstWToUppercase();
            task10.ParsePrice();
        }
Пример #26
0
 public void DivideByZeroExceptionTest(int a, int b, int c)
 {
     Assert.Throws <DivideByZeroException>(() => Task4.SolveLinearEquation(a, b, c));
 }
Пример #27
0
        static void Main(string[] args)
        {
            Func <Task4, char[, ]> TaskSolver = task =>
            {
                char[,] board = task.Board.Clone() as char[, ];

                int n = board.GetLength(0);
                int m = board.GetLength(1);

                for (int i = 1; i < n - 1; ++i)
                {
                    for (int j = 1; j < m - 1; ++j)
                    {
                        if (CheckInnerCell(task.Board, i, j))
                        {
                            board[i, j] = '1';
                        }
                        else
                        {
                            board[i, j] = '0';
                        }
                    }
                }

                for (int i = 0; i < n; ++i)
                {
                    //check top border and corners
                    if (CheckBoundaryCell(task.Board, i, 0))
                    {
                        board[i, 0] = '1';
                    }
                    else
                    {
                        board[i, 0] = '0';
                    }
                    //check down border and corners
                    if (CheckBoundaryCell(task.Board, i, m - 1))
                    {
                        board[i, m - 1] = '1';
                    }
                    else
                    {
                        board[i, m - 1] = '0';
                    }
                }

                for (int j = 1; j < m - 1; ++j)
                {
                    //check left border
                    if (CheckBoundaryCell(task.Board, 0, j))
                    {
                        board[0, j] = '1';
                    }
                    else
                    {
                        board[0, j] = '0';
                    }
                    //check right border
                    if (CheckBoundaryCell(task.Board, n - 1, j))
                    {
                        board[n - 1, j] = '1';
                    }
                    else
                    {
                        board[n - 1, j] = '0';
                    }
                }

                return(board);
            };

            Task4.CheckSolver(TaskSolver);
        }
Пример #28
0
 public static void TaskN4()
 {
     Task4.LoginPasswordValidation();
 }
Пример #29
0
        public static void Main(string[] args)
        {
            Console.Write("Please select the task(1-11): ");
            int taskNumber;

            while (true)
            {
                try
                {
                    taskNumber = int.Parse(Console.ReadLine());
                    if (taskNumber < 1 || taskNumber > 12)
                    {
                        throw new FormatException();
                    }
                    break;
                }
                catch (FormatException)
                {
                    Console.Write("Incorrect input, try again: ");
                }
            }
            switch (taskNumber)
            {
            case 1:
                Task1.Do();
                Program.Main(args);
                break;

            case 2:
                Task2.Do();
                Program.Main(args);
                break;

            case 3:
                Task3.Do();
                Program.Main(args);
                break;

            case 4:
                Task4.Do();
                Program.Main(args);
                break;

            case 5:
                Task5.Do();
                Program.Main(args);
                break;

            case 6:
                Task6.Do();
                Program.Main(args);
                break;

            case 7:
                Task7.Do();
                Program.Main(args);
                break;

            case 8:
                Task8.Do();
                Program.Main(args);
                break;

            case 9:
                Task9.Do();
                Program.Main(args);
                break;

            case 10:
                Task10.Do();
                Program.Main(args);
                break;
            }
        }
Пример #30
0
        public void FindNODTest(int a, int expected)
        {
            int actual = Task4.FindNOD(a);

            Assert.AreEqual(expected, actual);
        }