import random
class Critter(object):
"""A virtual pet"""
def __init__(self, name, hunger = 0, boredom = 0, cifra=0):
self.name = name
self.hunger = hunger
self.boredom = boredom
self.fact_name = cifra
def __pass_time(self):
self.hunger += 1
self.boredom += 1
@property
def mood(self):
unhappiness = self.hunger + self.boredom
if unhappiness < 5:
m = "happy"
elif 5 <= unhappiness <= 10:
m = "okay"
elif 11 <= unhappiness <= 15:
m = "frustrated"
else:
m = "mad"
return m
def talk(self):
print("имя: ", self.name, self.mood, "Голод: ", self.hunger, "уныние: ", self.boredom, "фактическое имя объекта: ", self.fact_name)
self.__pass_time()
def main():
#вот тут я генерирую нужное кол-во объектов
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
ferm = []
value_of_zver = random.randrange(0, 125)
for i in range(value_of_zver):
klichka_jivotnogo = ""
choice = ""
for k in range(1,8):
choice = random.choice(alphabet)
klichka_jivotnogo += str(choice)
hunger = random.randrange(0, 7)
boredom = random.randrange(0, 7)
name_of_object = i
i = Critter(klichka_jivotnogo, hunger, boredom, name_of_object)
ferm.append(i)
for i in ferm:
i.talk()
main()
aW1wb3J0IHJhbmRvbQpjbGFzcyBDcml0dGVyKG9iamVjdCk6CiAgICAiIiJBIHZpcnR1YWwgcGV0IiIiCiAgICBkZWYgX19pbml0X18oc2VsZiwgbmFtZSwgaHVuZ2VyID0gMCwgYm9yZWRvbSA9IDAsIGNpZnJhPTApOgogICAgICAgIHNlbGYubmFtZSA9IG5hbWUKICAgICAgICBzZWxmLmh1bmdlciA9IGh1bmdlcgogICAgICAgIHNlbGYuYm9yZWRvbSA9IGJvcmVkb20KICAgICAgICBzZWxmLmZhY3RfbmFtZSA9IGNpZnJhCgogICAgZGVmIF9fcGFzc190aW1lKHNlbGYpOgogICAgICAgIHNlbGYuaHVuZ2VyICs9IDEKICAgICAgICBzZWxmLmJvcmVkb20gKz0gMQoKICAgIEBwcm9wZXJ0eQogICAgZGVmIG1vb2Qoc2VsZik6CiAgICAgICAgdW5oYXBwaW5lc3MgPSBzZWxmLmh1bmdlciArIHNlbGYuYm9yZWRvbQogICAgICAgIGlmIHVuaGFwcGluZXNzIDwgNToKICAgICAgICAgICAgbSA9ICJoYXBweSIKICAgICAgICBlbGlmIDUgPD0gdW5oYXBwaW5lc3MgPD0gMTA6CiAgICAgICAgICAgIG0gPSAib2theSIKICAgICAgICBlbGlmIDExIDw9IHVuaGFwcGluZXNzIDw9IDE1OgogICAgICAgICAgICBtID0gImZydXN0cmF0ZWQiCiAgICAgICAgZWxzZToKICAgICAgICAgICAgbSA9ICJtYWQiCiAgICAgICAgcmV0dXJuIG0KICAgIAogICAgZGVmIHRhbGsoc2VsZik6CiAgICAgICAgcHJpbnQoItC40LzRjzogIiwgc2VsZi5uYW1lLCBzZWxmLm1vb2QsICLQk9C+0LvQvtC0OiAiLCBzZWxmLmh1bmdlciwgItGD0L3Ri9C90LjQtTogIiwgc2VsZi5ib3JlZG9tLCAi0YTQsNC60YLQuNGH0LXRgdC60L7QtSDQuNC80Y8g0L7QsdGK0LXQutGC0LA6ICIsIHNlbGYuZmFjdF9uYW1lKQogICAgICAgIHNlbGYuX19wYXNzX3RpbWUoKQogICAgCgogICAgCmRlZiBtYWluKCk6IAogICAgI9Cy0L7RgiDRgtGD0YIg0Y8g0LPQtdC90LXRgNC40YDRg9GOINC90YPQttC90L7QtSDQutC+0Lst0LLQviDQvtCx0YrQtdC60YLQvtCyCiAgICBhbHBoYWJldCA9IFsnYScsICdiJywgJ2MnLCAnZCcsICdlJywgJ2YnLCAnZycsICdoJywgJ2knLCAnaicsICdrJywgJ2wnLCAnbScsICduJywgJ28nLCAncCcsICdxJywgJ3InLCAncycsICd0JywgJ3UnLCAndicsICd3JywgJ3gnLCAneScsICd6J10KICAgIGZlcm0gPSBbXQoKICAgIHZhbHVlX29mX3p2ZXIgPSByYW5kb20ucmFuZHJhbmdlKDAsIDEyNSkKCiAgICBmb3IgaSBpbiByYW5nZSh2YWx1ZV9vZl96dmVyKToKCiAgICAgICAga2xpY2hrYV9qaXZvdG5vZ28gPSAiIgogICAgICAgIGNob2ljZSA9ICIiCiAgICAgICAgZm9yIGsgaW4gcmFuZ2UoMSw4KToKICAgICAgICAgICAgY2hvaWNlID0gcmFuZG9tLmNob2ljZShhbHBoYWJldCkKICAgICAgICAgICAga2xpY2hrYV9qaXZvdG5vZ28gKz0gc3RyKGNob2ljZSkKCiAgICAgICAgaHVuZ2VyID0gcmFuZG9tLnJhbmRyYW5nZSgwLCA3KQogICAgICAgIGJvcmVkb20gPSByYW5kb20ucmFuZHJhbmdlKDAsIDcpCgogICAgICAgIG5hbWVfb2Zfb2JqZWN0ID0gaQoKICAgICAgCiAgICAgICAgaSA9IENyaXR0ZXIoa2xpY2hrYV9qaXZvdG5vZ28sIGh1bmdlciwgYm9yZWRvbSwgbmFtZV9vZl9vYmplY3QpCgoKICAgICAgICBmZXJtLmFwcGVuZChpKQogICAgICAgIAogICAgICAgIAogICAgZm9yIGkgaW4gZmVybToKICAgICAgICBpLnRhbGsoKQoKbWFpbigp