Ejemplo n.º 1
0
        public static void Main()
        {
            Point3D firstPoint = new Point3D();
            Point3D secondPoint = new Point3D(2.5, 55556, 8);
            firstPoint.X = 5;
            Console.WriteLine(firstPoint.ToString());

            Point3D beginning = Point3D.StartignPoint;
            Console.WriteLine("The beginning of the coordinate system is {0}", beginning.ToString());

            double distance = DistanceCalculator.BetweenTwoPointsIn3D(beginning, firstPoint);
            Console.WriteLine("The distance between them is: " + distance);
            Console.WriteLine();

            Path3D path1 = new Path3D(firstPoint, secondPoint, beginning, firstPoint);

            Console.Write("Enter path name: ");
            string pathName = Console.ReadLine();

            while (!Storage.WritePath(path1, pathName))
            {
                Console.Write("Path with that name already exists. Enter diffrent name:");
                pathName = Console.ReadLine();
            }

            Console.WriteLine("File successfully created.\n");

            Path3D path2 = new Path3D(beginning, firstPoint, secondPoint);
            Storage.WritePath(path2, "Path2");

            Console.WriteLine(Storage.ReadPath("Path2"));
            Console.WriteLine();
            Console.WriteLine(Storage.ReadPath("Path"));
        }
Ejemplo n.º 2
0
        static void Main()
        {
            // 1.Create a structure Point3D to hold a 3D-coordinate {X, Y, Z} in the Euclidian 3D space.
            //Implement the ToString() to enable printing a 3D point.

            Point3D RandomPoint = new Point3D(1, 2, 3);
            Console.WriteLine("Random Point:");
            Console.WriteLine(RandomPoint.ToString());

            // 2. Add a private static read-only field to hold the start of the coordinate system – the point O{0, 0, 0}.
            // Add a static property to return the point O.
            Console.WriteLine("Starting Point O:");
            Console.WriteLine(Point3D.StartPoint());

            //3 Write a static class with a static method to calculate the distance between two points in the 3D space.
            Point3D PointA = new Point3D(1, 2, 3);
            Point3D PointB = new Point3D(4, 5, 6);
            Console.WriteLine("Calculate Distance between two points: ");
            Console.WriteLine(CalculationDistance.Distance(PointA, PointB));

            //4 Create a class Path to hold a sequence of points in the 3D space.
            //Create a static class PathStorage with static methods to save and load paths from a text file. Use a file format of your choice.
            Path pathList = new Path();
            pathList.path.Add(PointA);
            pathList.path.Add(PointB);
            Console.WriteLine("First point of sequence of points");
            Console.WriteLine(pathList.path[0]);
            //Save and load
            PathStorage.SavePath(pathList);
            Path LoadedList = PathStorage.LoadPath("../../path.txt");
        }
Ejemplo n.º 3
0
        static void Main()
        {
            Point3D newPoint = new Point3D(0, 1, 2);
            Console.WriteLine("Point 1: {0}", newPoint.ToString());
            Console.WriteLine(new string('=', 30));

            Point3D center = Point3D.GetCoordinateCenter;
            Console.WriteLine("Start: {0}", center.ToString());
            Console.WriteLine(new string('=', 30));

            Console.WriteLine("Distance between points = {0:F2}", Distance.Calculate(newPoint, center));
            Console.WriteLine(new string('=', 30));

            string filePath = "storage.txt";
            List<Point3D> points = new List<Point3D>();
            points.Add(newPoint);
            points.Add(center);
            Path3D path = new Path3D(points);
            Storage.Save(path, filePath);

            Path3D readPath = Storage.Load("storage.txt");
            int counter = 1;
            foreach (var point in readPath.Path)
            {
                Console.WriteLine("Point {3}: X = {0}, Y = {1}, Z = {2}", point.X, point.Y, point.Z, counter);
                counter++;
            }
            Console.WriteLine();
        }
Ejemplo n.º 4
0
        static void Main()
        {
            /*наясно съм че "Point3D ex1-ex2-ex3-ex4" не е добро наименование на проект,
             * правилно е да е "Point3D", добавих единствено това "ex1-ex2-ex3-ex4",
             * за да е прегледно за проверяващия кои задачи обхваща от домашното*/

            string fileName = @"../../../paths.txt";
            //string fileName = "c://test//path.txt";  //wrong path

            //ex.1
            Point3D point = new Point3D(3, 5, 7);
            Console.WriteLine(point.ToString());

            //ex.2 print zero point
            Point3D point1 = Point3D.Zero;
            Console.WriteLine(point1.ToString());

            //ex.3 print distance between two points
            Console.WriteLine("The distance between two pints is: {0:F8}", DistanceIn3DSpace.CalculateDistanceBetweenTwoPoints(point, point1));

            //ex.4 add point in path
            Path pathOfPoints = new Path();
            pathOfPoints.AddPoint(point);
            pathOfPoints.AddPoint(point1);

            //write paths in file
            PathStorage.SavePathsInFile(pathOfPoints, fileName);

            //load paths from file
            Path pathOfPointsLoad = new Path();
            pathOfPointsLoad = PathStorage.LoadPathsFromFile(fileName);

            Console.WriteLine("Print points from pathOfPointsLoad");
            pathOfPointsLoad.PrintPaths();
        }
Ejemplo n.º 5
0
        public static void Main(string[] args)
        {
            Point3D point         = new Point3D(2.5, 1, 3);
            Point3D startingPoint = Point3D.GetStartingPoint;

            //Homework Problem 1
            //Print point
            Console.WriteLine(point.ToString());

            //Homework Problem 1
            //Print starting point
            Console.WriteLine(startingPoint.ToString());

            //Homework Problem 2
            //Calculate and print dostance between point and starting point
            Console.WriteLine(DistanceCalculator.CalculateDistance(point, startingPoint));

            //Homework Problem 3
            //Create path and add two points
            Path3D path = new Path3D();

            path.AddPoint(point);
            path.AddPoint(startingPoint);

            //Save file
            Storage.SavePath(path, filePath);

            //Load file
            Console.WriteLine();
            Storage.LoadPath(filePath);
        }
Ejemplo n.º 6
0
        static void Main()
        {
            Point3D point = new Point3D(5, 2, 3);

            Console.WriteLine(point.ToString());

            Console.WriteLine(Point3D.StartingPoint);
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            Point3D some = new Point3D(0, 1, 2);

            Console.WriteLine(some.ToString());

            Point3D pO = Point3D.PointO;

            Console.WriteLine(pO.ToString());

            Path someP = new Path();

            someP.PointsList.Add(some);

            foreach (var p in someP.PointsList)
            {
                Console.WriteLine(p.ToString());
            }
        }
Ejemplo n.º 8
0
        public static void Main()
        {
            Point3D firstPoint  = new Point3D();
            Point3D secondPoint = new Point3D(2.5, 55556, 8);

            firstPoint.X = 5;
            Console.WriteLine(firstPoint.ToString());

            Point3D beginning = Point3D.StartignPoint;

            Console.WriteLine("The beginning of the coordinate system is {0}", beginning.ToString());

            double distance = DistanceCalculator.BetweenTwoPointsIn3D(beginning, firstPoint);

            Console.WriteLine("The distance between them is: " + distance);
            Console.WriteLine();

            Path3D path1 = new Path3D(firstPoint, secondPoint, beginning, firstPoint);

            Console.Write("Enter path name: ");
            string pathName = Console.ReadLine();

            while (!Storage.WritePath(path1, pathName))
            {
                Console.Write("Path with that name already exists. Enter diffrent name:");
                pathName = Console.ReadLine();
            }

            Console.WriteLine("File successfully created.\n");

            Path3D path2 = new Path3D(beginning, firstPoint, secondPoint);

            Storage.WritePath(path2, "Path2");

            Console.WriteLine(Storage.ReadPath("Path2"));
            Console.WriteLine();
            Console.WriteLine(Storage.ReadPath("Path"));
        }