Design Pattern Examples
Overview of object-oriented design patterns
DesignPatternExamples_python.state.state_exercise Namespace Reference

Functions

None _State_DisplayText (str textToDisplay)
 Helper method to display text from the State exercise.
 
def State_Exercise ()
 Example of using the State Pattern.
 

Function Documentation

◆ _State_DisplayText()

None _State_DisplayText ( str  textToDisplay)
protected

Helper method to display text from the State exercise.

Text is displayed with line numbers.

Parameters
textToDisplayText to display.

Definition at line 15 of file state_exercise.py.

Referenced by DesignPatternExamples_python.state.state_exercise.State_Exercise().

◆ State_Exercise()

def State_Exercise ( void  )

Example of using the State Pattern.

The State pattern alters the behavior of the class hierarchy based on some state. This is the basis of a Finite State Machine.

In this exercise, the State class is a filter that parses text to remove C++-style line and block comments. It needs to be smart enough to ignore comment characters inside quotes.

The filtering process starts with creating the context that drives the state machine. Internal classes are provided for each state.

Definition at line 36 of file state_exercise.py.

References DesignPatternExamples_python.state.state_exercise._State_DisplayText(), and DesignPatternExamples_python.state.state_exercise.State_Exercise().

Referenced by DesignPatternExamples_python.state.state_exercise.State_Exercise().