9using System.Collections.Generic;
29 public string Name {
get;
private set; }
36 public string Command {
get;
private set; }
91 Console.Write(
"move left");
120 Console.Write(
"move right");
149 Console.Write(
"move up");
178 Console.Write(
"move down");
251 List<MoveCommand> commands =
new List<MoveCommand>();
252 foreach (
char command
in moveList)
254 string testCommand = command.ToString().ToUpper();
280 commands.Add(moveCommand);
341 List<MoveCommand> commands =
_ParseMoves(moveList);
356 List<MoveCommand> commands =
_ParseMoves(moveList);
Represents an operation that can be applied to a TextObject. This class can handle two kinds of opera...
Represents the Move Down command.
MoveCommandDown(string command)
Constructor.
override void Execute()
Executes the move down command.
Base class that represents a move command. A move command has a name and the command character that r...
MoveCommand(string command, string commandName)
Constructor.
string Name
Name of the command (assigned in the class constructor).
abstract void Execute()
Execute the command. Derived classes must implement this.
void Show()
Display the move command and its name followed by a newline.
Represents the Move Left command.
override void Execute()
Executes the move left command.
MoveCommandLeft(string command)
Constructor.
Represents the Do Nothing command. This is the Null Object for this exercise.
MoveCommandNone(string command)
Constructor.
override void Execute()
Does nothing when executed (this is the Null Object, after all).
Represents the Move Right command.
MoveCommandRight(string command)
Constructor.
override void Execute()
Executes the move right command.
Represents the Move Up command.
MoveCommandUp(string command)
Constructor.
override void Execute()
Executes the move up command.
Represents the processor that translates the move list into a list of MoveCommand objects then either...
void _ShowMoves(List< MoveCommand > commands)
Display the command character and name of the command for each command in the given list of commands.
void ShowMoveList(string moveList)
Parse and display the given list of move commands, where each command is represents by a single chara...
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 ExecuteMoveList(string moveList)
Parse and execute the given list of move commands, where each command is represents by a single chara...
The namespace containing all Design Pattern Examples implemented in C#.