Represents the processor that translates the move list into a list of MoveCommand objects then either displays them or executes them. More...
Public Member Functions | |
void | ExecuteMoveList (string moveList) |
Parse and execute the given list of move commands, where each command is represents by a single character. | |
void | ShowMoveList (string moveList) |
Parse and display the given list of move commands, where each command is represents by a single character. | |
Private Member Functions | |
List< MoveCommand > | _ParseMoves (string moveList) |
Helper method to convert a list of single letter commands into a list of MoveCommand objects. | |
void | _ExecuteMoves (List< MoveCommand > commands) |
Helper method to execute all the given commands. | |
void | _ShowMoves (List< MoveCommand > commands) |
Display the command character and name of the command for each command in the given list of commands. | |
Represents the processor that translates the move list into a list of MoveCommand objects then either displays them or executes them.
This classes uses a parser to convert the single letter characters in a string into a list of actions (instances of the MoveCommand class). This list of actions is then executed to perform the operations.
This process of executing the list of operations is an example of the Command Pattern. This is also an example of the Interpreter Pattern, where the actions are the tokens to be interpreted.
Definition at line 231 of file Null_Object.cs.
|
inlineprivate |
Helper method to execute all the given commands.
commands | A list of MoveCommand objects to "execute". |
In this implementation, the MoveCommand object prints the command as "<move xxx> " on the current line. When all commands have been printed, a new line is printed to move to the next line. The "Do Nothing" command doesn't print anything, leaving only the empty <>.
Definition at line 301 of file Null_Object.cs.
Referenced by MoveProcessor.ExecuteMoveList().
|
inlineprivate |
Helper method to convert a list of single letter commands into a list of MoveCommand objects.
This method recognizes 'L', 'R', 'U', and 'D' (case-insensitive). All other characters default to the "Do Nothing" (Null Object) command.
moveList | A string containing a list of single letter commands to be parsed. |
Definition at line 249 of file Null_Object.cs.
Referenced by MoveProcessor.ExecuteMoveList(), and MoveProcessor.ShowMoveList().
|
inlineprivate |
Display the command character and name of the command for each command in the given list of commands.
commands | The list of MoveCommand objects to display. |
Definition at line 320 of file Null_Object.cs.
Referenced by MoveProcessor.ShowMoveList().
|
inline |
Parse and execute the given list of move commands, where each command is represents by a single character.
Recognizes 'U', 'D', 'L', and 'R' (case-insensitive). All other characters are assigned a "Do Nothing" (Null Object) command.
moveList | A string of characters to parse and execute. |
Definition at line 339 of file Null_Object.cs.
References MoveProcessor._ExecuteMoves(), and MoveProcessor._ParseMoves().
Referenced by NullObject_Exercise.Run().
|
inline |
Parse and display the given list of move commands, where each command is represents by a single character.
Recognizes 'U', 'D', 'L', and 'R' (case-insensitive). All other characters are assigned a "Do Nothing" (Null Object) command.
moveList | A string of characters to parse and display. |
Definition at line 354 of file Null_Object.cs.
References MoveProcessor._ParseMoves(), and MoveProcessor._ShowMoves().
Referenced by NullObject_Exercise.Run().