コード例 #1
0
ファイル: RoverTest.cs プロジェクト: diegobg/MarsRover
        public void ExecuteCommands()
        {
            _rover.AddCommand(new MoveCommand(50));
            _rover.AddCommand(new TurnCommand(TurnDirection.Left));
            _rover.AddCommand(new MoveCommand(23));
            _rover.AddCommand(new TurnCommand(TurnDirection.Left));
            _rover.AddCommand(new MoveCommand(4));

            var result = _rover.ExecuteCommands();

            Assert.AreEqual("4624 North", result.ToString());
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Console.WriteLine("----- INPUTS ----- ");
            //Get plateu boundaries
            string plateuBoundaries = Console.ReadLine();

            //Get First rover's instruction information and execution commands
            string firstRoverInstructions = Console.ReadLine();
            string firstRoverCommands     = Console.ReadLine();

            //Get Second rover's instruction information and execution commands
            string secondRoverInstructions = Console.ReadLine();
            string secondRoverCommands     = Console.ReadLine();


            Console.WriteLine("----- OUTPUTS -----");
            //Create Plateu boundaries
            Plateu plateu = new Plateu(plateuBoundaries);

            //Instantiate First Rover, Execute commands
            Rover firstRover = new Rover(firstRoverInstructions, plateu);

            firstRover.ExecuteCommands(firstRoverCommands.ToCharArray().ToList());
            firstRover.PrintRoverCurrentState();

            //Instantiate Second Rover, Execute commands
            Rover secondRover = new Rover(secondRoverInstructions, plateu);

            secondRover.ExecuteCommands(secondRoverCommands.ToCharArray().ToList());
            secondRover.PrintRoverCurrentState();

            Console.ReadKey();
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: diegobg/MarsRover
        private static void ExecuteCommands()
        {
            try
            {
                var result = _rover.ExecuteCommands();

                _flashMessage = FlashMessage.Success($"Rover position: {result}");
            }
            catch (Exception ex)
            {
                _flashMessage = FlashMessage.Error(ex.Message);
            }
        }