コード例 #1
0
        public static Path LoadPath(StreamReader reader)
        {
            Path path = new Path();

            using (reader)
            {
                string line = reader.ReadLine();
                while (line != null)
                {
                    int coordinatesStart = line.IndexOf("(");
                    string coordinates = line.Substring(coordinatesStart + 1, 7);

                    int[] pointCoordinates = coordinates.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries)
                        .Select(x => int.Parse(x))
                        .ToArray();

                    Point3D point = new Point3D(pointCoordinates[0], pointCoordinates[1], pointCoordinates[2]);
                    path.AddPoint(point);

                    line = reader.ReadLine();
                }
            }

            return path;
        }
コード例 #2
0
 static void Main()
 {
     Point3D firstPoint = new Point3D(1.3, 2.2, 3.3);
     Point3D secondPoint = new Point3D(1, 3, 4);
     Console.WriteLine(Distance.CalculateDistance(firstPoint,secondPoint));
     Path path = new Path();
     path.AddPoint(firstPoint);
     path.AddPoint(secondPoint);
     Console.WriteLine(path);
 }
コード例 #3
0
ファイル: Point3D.cs プロジェクト: antonpopov/TelerikAcademy
 static Point3D()
 {
     startPoint = new Point3D(0, 0, 0);
 }
コード例 #4
0
ファイル: Path.cs プロジェクト: antonpopov/TelerikAcademy
 public void AddPoint(Point3D point)
 {
     this.list.Add(point);
 }