Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. class Animal:
  2. #initialize attributes
  3.  
  4. def __init__(self,animal_type, name, mood):
  5. self.__animal_type = animal_type
  6. self.__name = name
  7. self.__mood = mood
  8.  
  9. # set methods
  10. def set_animal_type(self, animal_type):
  11. self.__animal_type = animal_type
  12.  
  13. def set_name(self, name):
  14. self.__name = name
  15.  
  16. def set_mood(self, mood):
  17. self.__mood = mood
  18.  
  19. #check mood
  20. def check_mood(self):
  21. integer = random.randint(1,3)
  22. if integer == 1:
  23. self.__mood = "happy"
  24. elif integer == 2:
  25. self.__mood = "hungry"
  26. elif integer == 3:
  27. self.__mood = "sleepy"
  28.  
  29.  
  30. #return methods
  31. def get_animal_type(self):
  32. return self.__animal_type
  33.  
  34. def get_name(self):
  35. return self.__name
  36.  
  37. def get_mood(self):
  38. return self.__mood
  39.  
  40. import Animal
  41.  
  42. an = input("enter aninal:")
  43. na = input("enter name:")
  44. mo = Animal.Animal.check_mood()
  45.  
  46. animals = Animal.Animal(an,na,mo)
  47.  
  48. print(animals.get_animal_type(), animals.get_name(), animals.get_mood())
  49.  
  50. mo = Animal.Animal.check_mood()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement