Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Miner():
- def __init__(self, gold, goldMax, money, moneyMax, cond):
- self.gold = gold
- self.goldMax = goldMax
- self.money = money
- self.moneyMax = moneyMax
- self.cond = cond
- def mineGold(self):
- self.gold += 1
- if self.gold <= 10:
- self.cond = False
- elif self.gold >= 10:
- self.cond = True
- def exchangeGold(self):
- self.money += self.gold
- self.gold = 0
- self.cond = False
- def beActive(self,state):
- if state == 0:
- self.mineGold()
- elif state == 1:
- self.exchangeGold()
- else:
- print 'Something is wrong.'
- class State():
- def __init__(self, state, statenum):
- self.state = state
- self.statenum = statenum
- def changeState(self, cond):
- if cond == True:
- self.state += 1
- if self.state > statenum - 1:
- self.state = 0
- elif self.state == False:
- self.state -= 1
- if self.state < 0:
- self.state = 1
- Bob = Miner(0,None,0, None, None)
- Zustand = State(0,2)
- while True:
- Zustand.changeState(Bob.cond)
- Bob.beActive(Zustand.state)
- print Bob.money, Bob.gold
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement