Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. class animal:
  2. '''동물이름과 다리의수 색상이 들어있는 animal클래스'''
  3. sound = '동물의 울음소리 바꾸기'
  4. def __init__(self, name, leg, color):
  5. self.__name = name
  6. self.leg = leg
  7. self.color = color
  8.  
  9. def animal_info(self):
  10. print('이름 : {}'.format(self.__name))
  11. print('다리개수 : {}'.format(self.leg))
  12. print('통상적인 색상 : {}'.format(self.color))
  13.  
  14. @classmethod
  15. def change_sound(cls,sound):
  16. cls.sound = sound
  17.  
  18. @property
  19. def name(self):
  20. return self.__name
  21. @name.setter
  22. def name(self,new_name):
  23. self.__name = new_name
  24. print('이름이 변경됨 : {}'.format(self.__name))
  25.  
  26.  
  27. class poketmon(animal):
  28. def __init__(self, name, leg, color, attack):
  29. super().__init__(name, leg, color)
  30. self.attack = attack
  31.  
  32. def poketmon_info(self):
  33. print('이름 : {}'.format(self.name))
  34. print('다리개수 : {}'.format(self.leg))
  35. print('통상적인 색상 : {}'.format(self.color))
  36. print('짱짱 센 공격기술 : {}'.format(self.attack))
  37.  
  38.  
  39.  
  40.  
  41. animal_ = animal('개','4개','겁나많음')
  42. animal_.animal_info()
  43. animal_.change_sound("왈왈왈 으르렁\n")
  44. print(animal_.sound)
  45.  
  46.  
  47. poketmon_ = poketmon('롱스톤','없음','회색','몸통박치기')
  48. poketmon_.poketmon_info()
  49. poketmon_.change_sound('롱스톤은 울지않아')
  50. print(poketmon_.sound)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement