Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            Point3D one = new Point3D(1, 2, 3);
            Point3D two = new Point3D(4, 5, 6);

            Console.WriteLine(DistanceCalculator.CalculateDistance(one, two));

            Path3D path1 = new Path3D();
            Path3D path2 = new Path3D();

            path2.AddPath(two);
            path2.AddPath(one);
            path1.AddPath(one);
            path1.AddPath(two);

            Storage.SavePaths(path1);
            Storage.SavePaths(path2);

            for (int i = 0; i < Storage.LoadPaths().Count; i++)
            {
                Console.Write("Path{0}: ", i + 1);
                for (int j = 0; j < Storage.LoadPaths()[i].Points.Count; j++)
                {
                    Console.Write(Storage.LoadPaths()[i].Points[j].ToString());
                    if (j < Storage.LoadPaths()[i].Points.Count - 1)
                    {
                        Console.Write(" - ");
                    }
                }
                Console.WriteLine();
            }
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Point3D one = new Point3D(1, 2, 3);
            Point3D two = new Point3D(4, 5, 6);

            Console.WriteLine(DistanceCalculator.CalculateDistance(one, two));

            Path3D path1 = new Path3D();
            Path3D path2 = new Path3D();


            path2.AddPath(two);
            path2.AddPath(one);
            path1.AddPath(one);
            path1.AddPath(two);

            Storage.SavePaths(path1);
            Storage.SavePaths(path2);

            for (int i = 0; i < Storage.LoadPaths().Count; i++)
            {
                Console.Write("Path{0}: ", i + 1);
                for (int j = 0; j < Storage.LoadPaths()[i].Points.Count; j++)
                {
                    Console.Write(Storage.LoadPaths()[i].Points[j].ToString());
                    if (j < Storage.LoadPaths()[i].Points.Count - 1)
                    {
                        Console.Write(" - ");
                    }
                }
                Console.WriteLine();
            }
        }
Ejemplo n.º 3
0
        public static List<Path3D> LoadPaths()
        {
            List<Path3D> paths = new List<Path3D>();
            try
            {
                StreamReader reader = new StreamReader("paths.txt");
                using (reader)
                {
                    string line = reader.ReadLine();
                    while (line != null)
                    {
                        Path3D path = new Path3D();
                        string[] pointsArr = line.Split(' ');
                        foreach (var point in pointsArr)
                        {
                            if (point != string.Empty)
                            {
                                int x = Convert.ToInt32(point[0] - 48);
                                int y = Convert.ToInt32(point[2] - 48);
                                int z = Convert.ToInt32(point[4] - 48);
                                path.AddPath(new Point3D(x, y, z));
                            }
                        }
                        paths.Add(path);
                        line = reader.ReadLine();
                    }
                }
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }

            return paths;
        }
Ejemplo n.º 4
0
        public static List <Path3D> LoadPaths()
        {
            List <Path3D> paths = new List <Path3D>();

            try
            {
                StreamReader reader = new StreamReader("paths.txt");
                using (reader)
                {
                    string line = reader.ReadLine();
                    while (line != null)
                    {
                        Path3D   path      = new Path3D();
                        string[] pointsArr = line.Split(' ');
                        foreach (var point in pointsArr)
                        {
                            if (point != string.Empty)
                            {
                                int x = Convert.ToInt32(point[0] - 48);
                                int y = Convert.ToInt32(point[2] - 48);
                                int z = Convert.ToInt32(point[4] - 48);
                                path.AddPath(new Point3D(x, y, z));
                            }
                        }
                        paths.Add(path);
                        line = reader.ReadLine();
                    }
                }
            }
            catch (IOException ioe)
            {
                Console.Error.WriteLine(ioe.Message);
            }

            return(paths);
        }