statemachine.py

来自「this is the most basic to learn python」· Python 代码 · 共 15 行

PY
15
字号
#: 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()
#:~

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?