Design Pattern Examples
Overview of object-oriented design patterns
NullObject_Exercise.cs
Go to the documentation of this file.
1
5
6using System;
7
9{
29 internal class NullObject_Exercise
30 {
34 // ! [Using NullObject in C#]
35 public void Run()
36 {
37 Console.WriteLine();
38 Console.WriteLine("Null Object Exercise");
39
40 MoveProcessor moveProcessor = new MoveProcessor();
41
42 // A stream of recognized and unrecognized move commands. The
43 // unrecognized commands do nothing.
44 string moveString = "ur#ld!lr";
45 Console.WriteLine(" Showing the move commands:");
46 moveProcessor.ShowMoveList(moveString);
47
48 Console.WriteLine(" Executing the move commands:");
49 Console.Write(" {0} -> ", moveString);
50 moveProcessor.ExecuteMoveList(moveString);
51
52 Console.WriteLine(" Done.");
53 }
54 // ! [Using NullObject in C#]
55 }
56}
Represents the processor that translates the move list into a list of MoveCommand objects then either...
Definition: Null_Object.cs:232
void ShowMoveList(string moveList)
Parse and display the given list of move commands, where each command is represents by a single chara...
Definition: Null_Object.cs:354
void ExecuteMoveList(string moveList)
Parse and execute the given list of move commands, where each command is represents by a single chara...
Definition: Null_Object.cs:339
Example of using the Null Object Pattern in C#.
void Run()
Executes the example for the Null Object Pattern in C#.
The namespace containing all Design Pattern Examples implemented in C#.