Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. class Miner():
  2. def __init__(self, gold, goldMax, money, moneyMax, cond):
  3. self.gold = gold
  4. self.goldMax = goldMax
  5. self.money = money
  6. self.moneyMax = moneyMax
  7. self.cond = cond
  8.  
  9. def mineGold(self):
  10. self.gold += 1
  11. if self.gold <= 10:
  12. self.cond = False
  13. elif self.gold >= 10:
  14. self.cond = True
  15.  
  16. def exchangeGold(self):
  17. self.money += self.gold
  18. self.gold = 0
  19. self.cond = False
  20.  
  21. def beActive(self,state):
  22. if state == 0:
  23. self.mineGold()
  24. elif state == 1:
  25. self.exchangeGold()
  26. else:
  27. print 'Something is wrong.'
  28.  
  29. class State():
  30. def __init__(self, state, statenum):
  31. self.state = state
  32. self.statenum = statenum
  33.  
  34. def changeState(self, cond):
  35. if cond == True:
  36. self.state += 1
  37. if self.state > statenum - 1:
  38. self.state = 0
  39. elif self.state == False:
  40. self.state -= 1
  41. if self.state < 0:
  42. self.state = 1
  43.  
  44. Bob = Miner(0,None,0, None, None)
  45. Zustand = State(0,2)
  46.  
  47. while True:
  48. Zustand.changeState(Bob.cond)
  49. Bob.beActive(Zustand.state)
  50. print Bob.money, Bob.gold
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement