Exemple #1
0
        static void Main()
        {
            //Create new point
            Point3D myPoint = new Point3D(2, 3, 4);
            Console.WriteLine(myPoint);
            Console.WriteLine(Point3D.Point0);

            //Calculate distance between two points
            double distance = PointCalculations.Point3DDistance(Point3D.Point0, myPoint);
            Console.WriteLine(distance);

            //Create new path and add elements
            Path testPath = new Path(myPoint);
            testPath.AddToPath(Point3D.Point0);

            //Save path in file
            PathStorage.SaveInFile(testPath);

            //Create new path and add points from file
            Path readTest = new Path();
            readTest = PathStorage.ReadFromFile();
            //Print readed from file points
            List<Point3D> points = new List<Point3D>();
            points = readTest.GetAllPathElements();
            foreach (var item in points)
            {
                Console.WriteLine(item);
            }
        }
Exemple #2
0
 /// <summary>
 /// Elements in file must be in format x y z
 /// New point is in new line
 /// </summary>
 /// <returns>Return Path</returns>
 public static Path ReadFromFile()
 {
     Path readedPath = new Path();
     string filePath = @"../../UsingFiles/TestRead.txt";
     using(StreamReader readFile = new StreamReader(filePath))
     {
         string line = readFile.ReadLine();
         while (line != null)
         {
             List<string> xyz = new List<string>(line.Split(' '));
             Point3D tempPoint3D = new Point3D();
             tempPoint3D.X = int.Parse(xyz[0]);
             tempPoint3D.Y = int.Parse(xyz[1]);
             tempPoint3D.Z = int.Parse(xyz[2]);
             readedPath.AddToPath(tempPoint3D);
             line = readFile.ReadLine();
         }
         Console.WriteLine("Job is DONE!");
     }
     return readedPath;
 }