コード例 #1
0
ファイル: Program.cs プロジェクト: AmaranthInHell/projects
        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();
            }
        }
コード例 #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();
            }
        }
コード例 #3
0
ファイル: Storage.cs プロジェクト: AmaranthInHell/projects
        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;
        }
コード例 #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);
        }