示例#1
0
        static void Main()
        {
            Point3D point = new Point3D(1, 2, 3);

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

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

            Console.WriteLine(distance);


            var path = new Path();

            for (int i = 0; i <= 20; 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);
            }
        }
示例#2
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);
            }
        }