コード例 #1
0
ファイル: Program.cs プロジェクト: gavjeffrey/MarsRover
        static void Main(string[] args)
        {
            Console.WriteLine("Rover Initialized. Press esc to disconnect.");

            var key = new ConsoleKeyInfo();

            Grid grid = GetGrid();

            do
            {
                GetCurrentPosition(out int x, out int y, out char orientation);

                var strMovements = GetMovementCommand();

                Rover rover = new Rover(x, y, orientation, grid);

                if (!rover.Move(strMovements))
                {
                    Console.WriteLine("Movement would result in invalid grid position, Rover stopped.");
                }

                Console.WriteLine("My current position is: {0}", rover.ReportPosition());

                Console.WriteLine("Press esc to exit. Press any other key to continue sending commands on this grid...");

                key = Console.ReadKey();
            }while (key.Key != ConsoleKey.Escape);
        }