Example #1
0
        static void Main(string[] args)
        {
            //Point3D tests
            Point3D pointOne = new Point3D(2, 3, 5);
            Point3D pointTwo = new Point3D(-1, -4, 0);

            Console.WriteLine("--------\nPoint3D tests:\n--------");
            Console.WriteLine("Point 1 coordinates: " + pointOne.ToString());
            Console.WriteLine("Point 2 coordinates: " + pointTwo.ToString());
            Console.WriteLine("Distance between points: " + Calculation.PointsDistance(pointOne, pointTwo));

            //Path tests
            string textFileOne = @"../../textfiles/fileOne.txt";
            string textFileTwo = @"../../textfiles/fileTwo.txt"; //изтрий всичко във fileTwo.txt и го провери след стартиране на програмата, за да видиш, че копира всичко от fileOne.txt

            PathStorage.ReadFromFile(textFileOne);
            PathStorage.WriteOnFile(textFileTwo, Path.ReturnPoints());


            //Generic tests
            GenericList <int> list = new GenericList <int>();

            for (int i = 0; i < 32; i++)
            {
                list.Add(i);
            }
            Console.WriteLine("--------\nGeneric tests:\n--------");

            Console.WriteLine("List ToString: \n" + list.ToString() + "\n");

            Console.WriteLine("Access pos 27 " + list.Access(27));

            list.Remove(27);
            Console.WriteLine("Position 27 after Remove: " + list.Access(27));

            list.Insert(1337, 28);
            Console.WriteLine("position 28: " + list.Access(28));

            Console.WriteLine("1337 found at pos: " + list.Find(1337));

            Console.WriteLine("Min: " + list.Min());
            Console.WriteLine("Max: " + list.Max());

            list.Clear();
            Console.WriteLine("\nList ToString after Clear: \n" + list.ToString() + "\n");

            Matrix <int> matrixOne    = new Matrix <int>(4, 5);
            Matrix <int> matrixTwo    = new Matrix <int>(4, 5);
            Matrix <int> resultmatrix = new Matrix <int>(4, 5);

            //Matrix<int> matrixOne = new Matrix<int>(4, 5);
            //Matrix<int> matrixTwo = new Matrix<int>(3, 5); това е за проба на Exception-а, когато матриците са с различен размер
            resultmatrix = matrixOne + matrixTwo;
            resultmatrix = matrixOne - matrixTwo;
            resultmatrix = matrixOne * matrixTwo;

            //не ми остана време за тест на Версията.
        }
Example #2
0
        static void Main(string[] args)
        {
            GenericList <int> newList = new GenericList <int>(3);

            Console.WriteLine("Capacity before adding an elements: ");
            Console.WriteLine(newList.Capacity);

            newList.Add(1);
            newList.Add(2);
            newList.Add(3);
            newList.Add(4);
            newList.Add(5);
            newList.Add(6);
            newList.Add(7);
            Console.WriteLine("The list after Adding elements from 1 to 7:");
            Console.WriteLine(newList);
            Console.WriteLine("Capacity after adding an elements: ");
            Console.WriteLine(newList.Capacity);

            newList.Insert(7, 8);
            newList.Insert(8, 9);
            newList.Insert(9, 10);
            newList.Insert(10, 11);
            newList.Insert(11, 12);
            Console.WriteLine("The list after Insert elements from 8 to 12 at positions from 7 to 11:");
            Console.WriteLine(newList);
            newList.RemoveAt(2);
            newList.RemoveAt(4);
            Console.WriteLine("The list after Remove elements in positions 2 and 4:");
            Console.WriteLine(newList);
            Console.WriteLine("The min element of the list is:");
            Console.WriteLine(newList.Min());
            Console.WriteLine("The max element of the list is:");
            Console.WriteLine(newList.Max());
            Console.WriteLine("The list after clear method:");
            newList.Clear();
            Console.WriteLine(newList);
            Console.WriteLine();

            Matrix <int> matrix1 = new Matrix <int>(3, 3);

            matrix1[0, 0] = 1;
            matrix1[0, 1] = 2;
            matrix1[0, 2] = 3;
            matrix1[1, 0] = 4;
            matrix1[1, 1] = 5;
            matrix1[1, 2] = 0;
            matrix1[2, 0] = 7;
            matrix1[2, 1] = 8;
            matrix1[2, 2] = 9;

            Matrix <int> matrix2 = new Matrix <int>(3, 3);

            matrix2[0, 0] = 1;
            matrix2[0, 1] = 2;
            matrix2[0, 2] = 3;
            matrix2[1, 0] = 4;
            matrix2[1, 1] = 5;
            matrix2[1, 2] = 6;
            matrix2[2, 0] = 7;
            matrix2[2, 1] = 8;
            matrix2[2, 2] = 9;
            Console.WriteLine("The sum of the matrix \n{0} \nand matrix \n{1} \nis:", matrix1, matrix2);
            Console.WriteLine(matrix1 + matrix2);
            Console.WriteLine("The division of the matrix \n{0} \nand matrix \n{1} \nis:", matrix1, matrix2);
            Console.WriteLine(matrix1 - matrix2);
            Console.WriteLine("The Product of the matrix \n{0} \nand matrix \n{1} \nis:", matrix1, matrix2);
            Console.WriteLine(matrix1 * matrix2);
            Console.WriteLine("Operator True for the matrix:");
            if (matrix1)
            {
                Console.WriteLine("The matrix: \n{0} \n has NO ZERO elements!", matrix1);
            }
            else
            {
                Console.WriteLine("The matrix:\n{0} \n HAS ZERO elements!", matrix1);
            }
            if (matrix2)
            {
                Console.WriteLine("The matrix:\n{0} \n has NO ZERO elements!", matrix2);
            }
            else
            {
                Console.WriteLine("The matrix: \n{0} \n HAS ZERO elements!", matrix2);
            }
        }