示例#1
0
        static void Main()
        {
            InputParser inputParser = new InputParser();
            IList<Rover> rovers = new List<Rover>();
            bool isValidInput;

            // read input
            isValidInput = inputParser.ReadInput(SampleInput);

            if(!isValidInput)
            {
                Console.WriteLine("Invalid input data");
                return;
            }

            // get grid boundary coordinates from the input
            IGridBoundary gridBoundary = inputParser.GridBoundary;
            Console.WriteLine(gridBoundary);

            // create and initialize each rover
            foreach (var roverInstruction in inputParser.RoverInstructions)
            {
                Console.WriteLine(roverInstruction.InitialPosition);
                Console.WriteLine(roverInstruction.Command);

                rovers.Add(new Rover(roverInstruction.InitialPosition, roverInstruction.Command, gridBoundary));
            }

            // process each rover and print its final location and orientation
            Console.WriteLine();
            foreach (var rover in rovers)
            {
                rover.Process();
                Console.WriteLine(rover.ToString());
            }

            Console.ReadLine();
        }
 public void SetupProcessor()
 {
     inputParser = new InputParser();
 }