Design Pattern Examples
Overview of object-oriented design patterns
nullobject_exercise.py
Go to the documentation of this file.
6
7from .null_object import MoveProcessor
8
9
26
27# ! [Using NullObject in Python]
29 print()
30 print("Null Object Exercise")
31
32 moveProcessor = MoveProcessor()
33
34 # A stream of recognized and unrecognized move commands. The
35 # unrecognized commands do nothing.
36 moveString = "ur#ld!lr";
37 print(" Showing the move commands:")
38 moveProcessor.ShowMoveList(moveString)
39
40 print(" Executing the move commands:")
41 print(" {0} -> ".format(moveString), end="")
42 moveProcessor.ExecuteMoveList(moveString)
43
44 print(" Done.")
45# ! [Using NullObject in Python]
Represents the processor that translates the move list into a list of MoveCommand objects then either...
Definition: null_object.py:163
def NullObject_Exercise()
Example of using the Null Object Pattern.