Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LaundryItem:
- allStates=["soak","wash","rinse","spin","dry","done"]
- def __init__(self):
- self.state=-1
- def nextCycle(self):
- self.state+=1
- if self.state<len(LaundryItem.allStates):
- return LaundryItem.allStates[self.state]
- return LaundryItem.allStates[-1]
- last=None
- def createLaundryItem():
- global last
- while True:
- if (last==None) or (last.state>=len(LaundryItem.allStates)):
- last=LaundryItem()
- return last
- def main():
- towel=createLaundryItem()
- print(towel.nextCycle())
- print(towel.nextCycle())
- print(towel.nextCycle())
- print(towel.nextCycle())
- print(towel.nextCycle())
- print(towel.nextCycle())
- print(towel.nextCycle())
- if __name__=="__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment