345449.vhj5l3oj7.asiaState.py2001-12-26T16:00:00Z2001-12-26T16:00:00Z<br/><TEXTAREA name="code" class="py" rows="16" cols="100">#: c04:statemachine:State.py
# A State has an operation, and can be moved
# into the next State given an Input:
class State:
def run(self):
assert 1, "run not implemented"
def next(self, input):
assert 1, "next not implemented"
#:~</TEXTAREA><br><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>2001-12-26T16:00:00ZStateMachine.py2001-12-26T16:00:00Z2001-12-26T16:00:00Z<br/><TEXTAREA name="code" class="py" rows="16" cols="100">#: c04:statemachine:StateMachine.py
# Takes a list of Inputs to move from State to
# State using a template method.
class StateMachine:
def __init__(self, initialState):
self.currentState = initialState
self.currentState.run()
# Template method:
def runAll(self, inputs):
for i in inputs:
print i
self.currentState = self.currentState.next(i)
self.currentState.run()
#:~</TEXTAREA><br><br/><script type="text/javascript"><!--google_ad_client = "pub-9426659565807829";google_ad_slot = "9359905831";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>2001-12-26T16:00:00Z