Exemplo n.º 1
0
        public void ProcessCommand()
        {
            var rawcommand = _commandReader.GetCommand();
            var command    = _commandManager.ChooseCommand(rawcommand);

            Console.WriteLine($"Valid command received: {command!=null}");

            if (command != null)
            {
                RobotPosition position = null;
                var           result   = command.GetCommandResult(_robot.RobotPosition, out position);
                Console.WriteLine($"Command performed by robot: {result}");
                if (result)
                {
                    if (command is PlaceCommand || command is LeftCommand || command is RightCommand || command is MoveCommand)
                    {
                        _robot.UpdatePosition(position);
                    }
                    else if (command is ReportCommand)
                    {
                        _reportDisplay.ShowRobot(_robot);
                    }
                }
            }
        }