Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- class Man:
- def __init__(self, name):
- self.name = name
- self.mood = 50
- self.money = 0
- self.cat_food = 0
- def status(self):
- print('Я - {}, настроение на {}, денег - {}'.format(self.name, self.mood, self.money))
- def go_work(self):
- print('{} пошел на работу'.format(self.name))
- self.money += 50
- self.mood -= 10
- def play_DOTA(self):
- print('{} играл в доту целый день'.format(self.name))
- self.mood += 20
- def pick_up_the_cat(self, cat):
- print('{} подобрал кота {}'.format(self.name, cat.name))
- self.cat = cat
- cat.man = self
- self.mood += 10
- def buy_cat_food(self):
- print('{} купил кошачьей еды'.format(self.name))
- self.cat_food += 50
- self.money -= 50
- def act(self):
- dice = randint(1, 6)
- if dice == 1:
- self.go_work()
- else:
- self.play_DOTA()
- class Cat:
- def __init__(self, name):
- self.name = name
- self.mood = 10
- self.fullness = 10
- self.man = None
- def status(self):
- print('Я - {}, настроение на {}, сытость - {}'.format(self.name, self.mood, self.fullness))
- def sleep(self):
- self.mood += 10
- self.fullness -= 10
- print('{} спал целый день'.format(self.name))
- def eat(self):
- if self.man is None:
- print('{}: я безхозный! '.format(self.name))
- else:
- if self.man.cat_food and self.man.cat_food > 10:
- print('{} поел '.format(self.name))
- self.man.cat_food -= 10
- self.fullness += 10
- else:
- print('{}: у меня нет еды! Мяу!'.format(self.name))
- def act(self):
- if self.fullness <= 0:
- print('Кот {} умер...'.format(self.name))
- return
- dice = randint(1, 6)
- if dice == 1:
- self.eat()
- else:
- self.sleep()
- vasya = Man(name='Вася')
- murzik = Cat(name='Мурзик')
- murzik.status()
- murzik.eat()
- vasya.pick_up_the_cat(cat=murzik)
- murzik.eat()
- vasya.buy_cat_food()
- murzik.eat()
- murzik.status()
- for day in range(1, 21):
- print('День {} ------------------'.format(day))
- vasya.act()
- murzik.act()
- vasya.status()
- murzik.status()
Add Comment
Please, Sign In to add comment