Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Animal:
- #initialize attributes
- def __init__(self,animal_type, name, mood):
- self.__animal_type = animal_type
- self.__name = name
- self.__mood = mood
- # set methods
- def set_animal_type(self, animal_type):
- self.__animal_type = animal_type
- def set_name(self, name):
- self.__name = name
- def set_mood(self, mood):
- self.__mood = mood
- #check mood
- def check_mood(self):
- integer = random.randint(1,3)
- if integer == 1:
- self.__mood = "happy"
- elif integer == 2:
- self.__mood = "hungry"
- elif integer == 3:
- self.__mood = "sleepy"
- #return methods
- def get_animal_type(self):
- return self.__animal_type
- def get_name(self):
- return self.__name
- def get_mood(self):
- return self.__mood
- import Animal
- an = input("enter aninal:")
- na = input("enter name:")
- mo = Animal.Animal.check_mood()
- animals = Animal.Animal(an,na,mo)
- print(animals.get_animal_type(), animals.get_name(), animals.get_mood())
- mo = Animal.Animal.check_mood()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement