コード例 #1
0
ファイル: Main.cs プロジェクト: niksmanov/Telerik_Academy
        static void Main()
        {
            Point3D firstPoint  = new Point3D(1, 2, 3);
            Point3D secondPoint = new Point3D(4, 5, 6);
            Point3D thirdPoint  = new Point3D(7, 8, 9);

            Path path = new Path();

            path.AddPoints(firstPoint, secondPoint, thirdPoint);
            PathStorage.SavePath(path);

            Path readPath = PathStorage.LoadPath();

            Console.WriteLine(readPath);
        }
コード例 #2
0
        static void Main()
        {
            Console.WriteLine("First to test the paths:");
            Point3D a = new Point3D(2, -5, 3.5);
            Point3D b = new Point3D(-2, 25, 4.8);

            Console.WriteLine("Creating 2 point and print them:");
            Console.WriteLine(a);
            Console.WriteLine(b);
            Console.WriteLine("Here is the static start: " + Point3D.PrintZero());
            Console.WriteLine("The distance between these two points is: " + StatisClass.Distance(a, b));
            Console.WriteLine("Read 4 points from txt and displaying them:");
            Path myPath = new Path(PathStorage.LoadPath());

            Console.WriteLine(myPath[0].ToString());
            Console.WriteLine(myPath[1].ToString());
            Console.WriteLine(myPath[2].ToString());
            Console.WriteLine(myPath[3].ToString());
            Console.WriteLine("And now save them to output.txt");
            PathStorage.SavePath(myPath);
            Console.WriteLine();
            Console.WriteLine("Now to test the Generic list. Create new list with size 2 and add two itens");
            GenericList <int> list = new GenericList <int>(2);

            list.Add(85);
            list.Add(12);
            Console.WriteLine(list);
            Console.WriteLine("Add one more item and let the list expand:");
            list.Add(-5);
            Console.WriteLine(list);
            Console.WriteLine("Print element at index 2: " + list[2]);
            list.RemoveAt(1);
            Console.WriteLine("Remove elemect at index 1: " + list);
            list.InsertAt(1, 99);
            Console.WriteLine("Insert elemect at index 1: " + list);
            Console.WriteLine("99 is which what index in the list: " + list.IndexOf(99));
            Console.WriteLine("Smallest element in the list is: " + list.Min());
            Console.WriteLine("Biggest element in the list is: " + list.Max());

            list.Clear();
            Console.WriteLine("Clearing the list." + list);

            Console.WriteLine("Now to test the matrixes: creating two matrixes: { 4, 3 }, { 2, 1 } and { 2, 1 }, { 4, 3 }, and them executing the 3 operations:");
            Matrix <int> firstMatrix  = new Matrix <int>(2, 2);
            Matrix <int> secondMatrix = new Matrix <int>(2, 2);

            int[,] sMatrix = new int[, ] {
                { 4, 3 }, { 2, 1 }
            };
            int[,] cMatrix = new int[, ] {
                { 2, 1 }, { 4, 3 }
            };
            for (int row = 0; row < 2; row++)
            {
                for (int col = 0; col < 2; col++)
                {
                    firstMatrix[row, col]  = sMatrix[row, col];
                    secondMatrix[row, col] = cMatrix[row, col];
                }
            }
            Console.WriteLine("Addition:");
            Matrix <int> newOne = firstMatrix + secondMatrix;

            for (int row = 0; row < 2; row++)
            {
                for (int col = 0; col < 2; col++)
                {
                    Console.Write(newOne[row, col] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("Subtraction:");
            newOne = firstMatrix - secondMatrix;
            for (int row = 0; row < 2; row++)
            {
                for (int col = 0; col < 2; col++)
                {
                    Console.Write(newOne[row, col] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("Multiplication:");
            newOne = firstMatrix * secondMatrix;
            for (int row = 0; row < 2; row++)
            {
                for (int col = 0; col < 2; col++)
                {
                    Console.Write(newOne[row, col] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine("Atributes:");
            Type type = typeof(Test);

            object[] attr = type.GetCustomAttributes(false);
            foreach (VersionAttribute item in attr)
            {
                Console.WriteLine(item.Version);
            }
        }
コード例 #3
0
        public static void Main()
        {
            //Initializing 3D points
            var firstPoint  = new Point3D(1, 2, 3);
            var secondPoint = new Point3D(2, 2, 3);

            Console.WriteLine(firstPoint);
            Console.WriteLine(secondPoint);

            //Printing distance between two points
            Console.WriteLine("Distance between points: {0}", Distance.CalculateDistance(firstPoint, secondPoint));
            //Console.WriteLine("Distance between points: {0}", Distance.CalculateDistance(firstPoint, Point3D.Point0));

            //Initializing points
            var path = new Path();

            for (int i = 0; i < 5; i++)
            {
                path.AddPoints(new Point3D(i + 2, i + 2, i + 2));
            }

            //Saving points in file
            PathStorage.SavePath(path, "pathstorage.txt");
            //Loading point from file
            var print = PathStorage.LoadPath("pathstorage.txt");

            //And printing it on the console
            foreach (var item in print)
            {
                Console.WriteLine(item);
            }

            var list = new GenericList <int>(3);

            //Adding elements
            list.AddElement(5);
            list.AddElement(18);
            list.AddElement(100);

            //Removing element by index
            list.RemoveElement(1);

            list.AddElement(90);

            //Inserting element at given index
            list.InsertElement(1, 10000);

            list.AddElement(123);

            Console.WriteLine(list);

            //Get element at index
            Console.WriteLine(list.GetElement(1));

            //Get min element
            Console.WriteLine(list.GetMinEl());

            //Get max element
            Console.WriteLine(list.GetMaxEl());

            //Clear the list
            list.ClearElements();

            Console.WriteLine(list);
        }