9from .adapter
import Adapter_Exercise
10from .bridge
import Bridge_Exercise
11from .command
import Command_Exercise
12from .composite
import Composite_Exercise
13from .decorator
import Decorator_Exercise
14from .facade
import Facade_Exercise
15from .flyweight
import Flyweight_Exercise
16from .handlerchain
import HandlerChain_Exercise
17from .interpreter
import Interpreter_Exercise
18from .iterator
import Iterator_Exercise
19from .mediator
import Mediator_Exercise
20from .memento
import Memento_Exercise
21from .nullobject
import NullObject_Exercise
22from .observer
import Observer_Exercise
23from .proxy
import Proxy_Exercise
24from .state
import State_Exercise
25from .strategy
import Strategy_Exercise
26from .visitor
import Visitor_Exercise
28from .version
import app_version
68 def Help(self, exercises: list[Exercise]):
70 "{0} v({1}) by Stephen P. Lepisto\n" + \
71 "usage: {0} [--help][-?][options] [exercise_name][[ exercise_name][...]]\n" + \
73 "Runs through a series of exercises showing off design patterns. If no exercise_name\n" + \
74 "is given, then run through all exercises.\n" + \
78 " This help text.\n" + \
80 " Show just the version number of this application.\n"
82 print(usage.format(
"DesignPatternExamples_python", app_version))
84 print(
"Exercises available:")
85 for exercise
in exercises:
86 print(
" {0}".format(exercise.name))
105 for argument
in args:
106 if argument
in [
"--help",
"-?",
"/?"]:
110 elif argument
in [
"--version"]:
114 options.exercise_names.append(argument)
145 for exercise
in exercises:
146 if len(options.exercise_names) == 0
or exercise.name
in options.exercise_names:
147 exercise.exercise_to_run()
Represents a single exercise or example for a design pattern.
exercise_to_run
Method to call to run the exercise.
def __init__(self, exercise_name, exercise)
Constructor.
name
Name of the exercise.
Represents the command line options provided to the program, if any.
def __init__(self)
Constructor.
Contains all the top-level Design Pattern Examples to match C#.
bool ParseOptions(self, args, Options options, exercises)
Helper method to parse the given options and store the results in the given Options structure.
def Run(self, args=None)
Run the specified examples.
def ShowVersion(self)
Helper method to show just the version of the application.
def Help(self, list[Exercise] exercises)
Helper method to show usage information for this program.
static void ShowVersion(void)
Helper function to show just the version of the application.