class Conversation (object): def __init__(self): self._state = None self.allStates = [] self.coffeeServed = False self.ended = False self.name = "" #later, should become userID and db-link object self.coffeeNames = ["vanilla", "chocolate", "caramel", "the blue one"] def startServeTimer(self): threading.Timer(3, self.doneServing).start() def doneServing(self): self.coffeeServed = True def listen(self): i = raw_input('>> ') return i def start(self): self._state = SActive() def run(self): while True: nextState = self._state.run(self) self.allStates.append(self._state.__class__.__name__) if not self.ended: self._state = nextState def end(self): self.ended = True print self.allStates self.allStates = [] self._state = SPassive()
def end(self): self.ended = True print self.allStates self.allStates = [] self._state = SPassive()
def start(self): self._state = SActive()