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; }
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); }
static Point3D() { startPoint = new Point3D(0, 0, 0); }
public void AddPoint(Point3D point) { this.list.Add(point); }