Ejemplo n.º 1
0
        public static void Main()
        {
            Point3D firstPoint = new Point3D(12.3, 4.7, 7.12);

            Console.WriteLine(firstPoint.ToString());
            Console.WriteLine(new string('=', 30));
            Point3D secondPoint = new Point3D(7.12, 12.3, 4.7);

            Console.WriteLine(secondPoint.ToString());
            Console.WriteLine(new string('=', 30));
            Console.WriteLine(DistanceCalc.Distance(firstPoint, secondPoint));
            Console.WriteLine(new string('=', 30));

            Path anyPath = new Path();

            anyPath.AddPoint(firstPoint);
            anyPath.AddPoint(secondPoint);

            PathStorage.SavePath(anyPath);

            Path loadedPath = new Path();

            PathStorage.LoadPath(loadedPath);
            for (int i = 0; i < loadedPath.ListOfPoints.Count; i++)
            {
                Console.WriteLine(loadedPath.ListOfPoints[i].ToString());
            }
        }
        static void Main()
        {
            Point3D point = new Point3D(1, 2, 3);

            Console.WriteLine(point);
            Console.WriteLine(Point3D.Origin);

            var dist = Point3DExtensions.CalculateDistance(point, Point3D.Origin);

            Console.WriteLine(dist);

            var path = new Path();

            for (int i = 0; i < 10; i++)
            {
                path.AddPoint(new Point3D()
                {
                    X = i, Y = i * 2, Z = i + 3
                });
            }

            string pathStr = "../../path.txt";

            PathStorage.SavePath(path, pathStr);
            var pathFromFile = PathStorage.LoadPath(pathStr);

            foreach (var p in pathFromFile)
            {
                Console.WriteLine(p);
            }
        }
Ejemplo n.º 3
0
        public static void Main()
        {
            Point3D coordinateBeginning = Point3D.O;

            Console.WriteLine(coordinateBeginning);

            Point3D firstPoint = new Point3D(3, 4, 3.75);

            Console.WriteLine(Distance.CalculateDistance(firstPoint, coordinateBeginning));

            Point3D[] samplePath = new Point3D[10];
            for (int i = 0; i < samplePath.Length; i++)
            {
                // calculate some strange coordinates just for testing
                double x = (3 * i * i) - (4 * i) - 5;
                double y = (i * i) - (2 * i) + 8;
                double z = (4 * i) - 10;
                samplePath[i] = new Point3D(x, y, z);
            }

            Path journey = new Path("My trip", samplePath);

            journey.AddPointsToPath(firstPoint);
            Console.WriteLine(journey);

            //Console.WriteLine(journey[15]); // Out of range exeption

            PathStorage.SavePath(journey, "test.txt");

            Path secondJourney = PathStorage.OpenPath("test.txt");

            // Path thirdJourney = PathStorage.OpenPath("tes.txt"); // File not found exception
        }
Ejemplo n.º 4
0
        static void Main()
        {
            Point3D point = new Point3D(1, 2, 3);

            // Problem 1. Structure
            Console.WriteLine(point);

            // Problem 2. Static read-only field
            Console.WriteLine(Point3D.Origin);

            // Problem 3. Static class
            var distance = Point3DExtensions
                           .CalculateDistance(point, Point3D.Origin);

            Console.WriteLine(distance);

            // Problem 4. Path
            var path = new Path();

            for (int i = 0; i < 10; i++)
            {
                path.AddPoint(new Point3D()
                {
                    X = i, Y = i * 2, Z = i + 3
                });
            }

            string pathStr = "../../path.txt";

            PathStorage.SavePath(path, pathStr);
            var pathFromFile = PathStorage.LoadPath("../../path.txt");

            foreach (var p in pathFromFile)
            {
                Console.WriteLine(p);
            }
        }