powie mi ktoś czemu funkcja str(objekt) mi nie działa, oraz mój switch?
import sys
class Pet():
def __init__(self, name):
print("Tworzę " + name)
self.name = name
self.hunger = 0
self.tiredness = 0
self.main()
def __del__(self):
print("googbye")
def play(self, fun = 4):
self.tiredness -= fun;
self.__passage_of_time()
def __passage_of_time(self):
self.hunger += 1
self.tiredness += 1
def eat(self, food = 4):
self.hunger -= food
self.__passage_of_time()
def angry_pet(self):
self.tiredness += 5
def talk(self):
mood = self.hunger + self.tiredness
if(mood < 5):
print("I'm happy")
elif(mood >= 5 and mood < 10):
print("It's okay")
elif(mood >= 10 and mood < 15):
print("I'm nervous")
elif(mood >= 15):
print("I'm angryy")
self.__passage_of_time()
def __str__(self):
return 'Name:{}\nHunger:{}\nTiredness:{}\n'.format(self.name, self.hunger, self.tiredness)
def switch(self, argument):
switcher = {
1: self.play,
2: self.eat,
3: self.talk,
0: self.__del__,
'xy': self.__str__
}.get(argument, 3)
def main(self):
choice = 1
while(choice):
print('1.play with pet')
print('2.feed pet')
print('3.talk with pet')
print('0.end')
choice = input('Your choice:')
if(choice == 1):
how_much = input('How long:')
for i in range(0, how_much + 1):
self.switch(choice)
else:
self.switch(choice)
print()
obj = Pet("Oskar")
str(Pet)