Esempio n. 1
0
        /// <summary>
        /// Gets a singleton instance for the parser
        /// </summary>
        /// <param name="rover">A valid Rover object</param>
        /// <returns>The RoverOperationParser object</returns>
        /// <exception cref="ArgumentNullException"></exception>
        public static RoverOperationParser GetParser(Rover rover)
        {
            if (_singleton == null)
            {
                _singleton = new RoverOperationParser();
            }

            if (rover == null)
            {
                throw new ArgumentNullException("rover");
            }

            _singleton.Rover = rover;
            return(_singleton);
        }
Esempio n. 2
0
 /// <summary>
 /// Computes the provided command literal.
 /// If valid, performs all the commands for the Rover object. Otherwise throws a exception.
 /// </summary>
 /// <param name="inputLiteral">The command literal to compute</param>
 /// <param name="rover">The current Rover that will be affected</param>
 public void ComputeMovements(string inputLiteral, Rover rover)
 {
     RoverBoardFacade.ValidateInput(this, inputLiteral, rover);
     RoverOperationParser.GetParser(rover).ParseOperations(inputLiteral);
 }