Exemple #1
0
 /// <summary>
 /// Sets the errorMessage member variable
 /// </summary>
 /// <param name="action">Name of the Command</param>
 /// <param name="isInitialized">denotes whether a valid PLACE command has been placed already</param>
 private void SetErrorMessage(TurtleInstruction action, bool isInitialized)
 {
     this.errorMessage = isInitialized ?
                         string.Format("Turtle cannot {0} there.", action.ToString().ToUpper()) :
                         string.Format("Turtle cannot {0} until it has been placed on the table.", action.ToString().ToUpper());
 }
 /// <summary>
 /// Strategy Pattern Execution of Commands
 /// </summary>
 /// <param name="instruction">Command Name</param>
 /// <param name="turtle">a turtle object</param>
 /// <param name="arguments">optional parameters</param>
 /// <param name="message">massage after command execution completed</param>
 /// <returns>command execution status</returns>
 public static bool DoExecution(TurtleInstruction instruction, ITurtle turtle, string[] arguments, out string message)
 {
     return(strategies[instruction].DoExecution(turtle, arguments, out message));
 }