Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import os
  2. import sys
  3. import random
  4.  
  5. #Class
  6. class Animal:
  7. __name=""
  8. __height= 0
  9. __weight= 0
  10. __sound= 0
  11.  
  12. #Constructor
  13. def __int__(self,name,height,weight,sound):
  14. self.__name=name
  15. self.__height=height
  16. self.__weight=weight
  17. self.__sound=sound
  18.  
  19. def set_name(self,name):
  20. self.__name=name
  21.  
  22. def get_name(self):
  23. return self.__name
  24.  
  25. def set_height(self, height):
  26. self.__height = height
  27.  
  28. def get_height(self):
  29. return self.__height
  30.  
  31. def set_weight(self,weight):
  32. self.__weight =weight
  33.  
  34. def get_weight(self):
  35. return self.__weight
  36.  
  37. def set_sound(self,sound):
  38. self.__sound=sound
  39.  
  40. def get_sound(self):
  41. return self.__sound
  42.  
  43. def get_type(self):
  44. print("Animal")
  45.  
  46. def toString(self):
  47. return "{} is {} cm tall and {} kilograms and say{}".format(self.__name,self.__height,self.__weight,self.__sound)
  48. cat=Animal('Whiskers',33,10,'Meow')
  49. print(cat.toString())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement