Пример #1
0
 public static void SavePath(Path path)
 {
     StreamWriter writer = new StreamWriter(@"..\..\ouput.txt");
     using (writer)
     {
         writer.WriteLine(path.ToString());
     }
 }
Пример #2
0
        public static void SavePath(Path spacePath)
        {
            while (true)
            {
                for (int i = count; i < MAX_NUMBER_OF_FILES; i++)
                {
                    string currentFilePath = PATH + FILE_NAME + i.ToString() + EXTENSION;
                    if (!File.Exists(currentFilePath))
                    {
                        File.WriteAllText(currentFilePath, spacePath.ToString());
                        count = i;
                        return;
                    }
                }

                DeleteSaveFiles();
                count = 0;
            }
        }
Пример #3
0
        static void Main()
        {
            Point3D p1 = new Point3D(2, 3.5, 6);
            Point3D p2 = new Point3D(2.1, 4, 41);
            Point3D p3 = new Point3D(0, 8.8, -5);

            Console.WriteLine("The center of the coordinate system {0}", Point3D.O.ToString());
            Console.WriteLine("A point {0}", p3.ToString());
            Console.WriteLine("The distance between points p1 {0} and p2 {1} is: {2:F2}",
                p1.ToString(), p2.ToString(), Distance.CalculateDistance(p1, p2));

            Path path = new Path();
            path.AddPoint(p1);
            path.AddPoint(p2);
            path.AddPoint(p3);
            Console.WriteLine("A path from 3 points: {0}", path.ToString());
            Console.Write("Loaded point from file:");
            PathStorage.LoadPath(@"..\..\points.txt");
            Console.WriteLine("Points p1,p2,p3 are saved in file.");
            PathStorage.SavePath(path);
        }
Пример #4
0
        public static void LoadPath(string pathDir)
        {
            StreamReader reader = new StreamReader(pathDir);
            Path paths = new Path();

            using (reader)
            {
                string line = reader.ReadLine();
                while (line != null)
                {
                    double[] arr = line
                                   .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                                   .Select(double.Parse)
                                   .ToArray();
                    Point3D point = new Point3D(arr[0], arr[1], arr[2]);
                    paths.AddPoint(point);
                    line = reader.ReadLine();
                }

                Console.WriteLine(paths.ToString());
            }
        }