示例#1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Insert File Name With Format :");

            string fileName = Console.ReadLine();
            string path     = EnvironmentPath + "\\" + fileName;;

            string[][] inputText = FileManager.Read(path, ' ');

            InputParsed dataForPathfinder = Parser.ParseInputData(inputText);

            //string[][] outputData = Parser.ParseOutputData();
            string[][] outputData = inputText;

            FileManager.Write(outputData, EnvironmentPath + "\\" + "output.txt", ' ');

            Console.WriteLine("Data Writed in output.txt");
            Console.WriteLine("Press ESC to terminate.");

            ConsoleKeyInfo pressedKey = Console.ReadKey();

            if (pressedKey.Key == ConsoleKey.Escape)
            {
                return;
            }
        }
示例#2
0
文件: Parser.cs 项目: TheL94/ProjectC
        public static InputParsed ParseInputData(string[][] _arrayToParse)
        {
            InputParsed returnData = new InputParsed();

            for (int i = 0; i < _arrayToParse.Length; i++)
            {
                if (i == 0)
                {
                    returnData.StartPoint   = new Point();
                    returnData.StartPoint.X = Int32.Parse(_arrayToParse[i][0]);
                    returnData.StartPoint.Y = Int32.Parse(_arrayToParse[i][1]);

                    returnData.ObjectivePoint   = new Point();
                    returnData.ObjectivePoint.X = Int32.Parse(_arrayToParse[i][2]);
                    returnData.ObjectivePoint.Y = Int32.Parse(_arrayToParse[i][3]);
                }
                else if (i == 1)
                {
                    int numberOfObstacles = Int32.Parse(_arrayToParse[i][0]);
                    returnData.Obstacles = new Polygonal[numberOfObstacles];
                }
                else
                {
                    for (int j = 0; j < _arrayToParse[i].Length; j++)
                    {
                        returnData.Obstacles[i - 2]          = new Polygonal();
                        returnData.Obstacles[i - 2].Vertexes = new Point[3];

                        returnData.Obstacles[i - 2].Vertexes[0]   = new Point(returnData.Obstacles[i - 2]);
                        returnData.Obstacles[i - 2].Vertexes[0].X = Int32.Parse(_arrayToParse[i][0]);
                        returnData.Obstacles[i - 2].Vertexes[0].Y = Int32.Parse(_arrayToParse[i][1]);

                        returnData.Obstacles[i - 2].Vertexes[1]   = new Point(returnData.Obstacles[i - 2]);
                        returnData.Obstacles[i - 2].Vertexes[1].X = Int32.Parse(_arrayToParse[i][2]);
                        returnData.Obstacles[i - 2].Vertexes[1].Y = Int32.Parse(_arrayToParse[i][3]);

                        returnData.Obstacles[i - 2].Vertexes[2]   = new Point(returnData.Obstacles[i - 2]);
                        returnData.Obstacles[i - 2].Vertexes[2].X = Int32.Parse(_arrayToParse[i][4]);
                        returnData.Obstacles[i - 2].Vertexes[2].Y = Int32.Parse(_arrayToParse[i][5]);
                    }
                }
            }

            return(returnData);
        }