예제 #1
0
        public void Compute(string operations)
        {
            foreach (var @operator in operations.ToCharArray())
            {
                if (@operator == '^')
                {
                    // Create command operation and execute it
                    var command = new RobotMoveForwardCommand(_robot);
                    command.Execute();
                }

                if (@operator == '<')
                {
                    // Create command operation and execute it
                    var command = new RobotTurnLeftCommand(_robot);
                    command.Execute();
                }

                if (@operator == '>')
                {
                    // Create command operation and execute it
                    var command = new RobotTurnRightCommand(_robot);
                    command.Execute();
                }

                writer.Write(_robot.GetLocation());
            }
        }