SMALL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | # -*- coding: utf-8 -*- import random import sys import os class Animal(object): __name = "" __height = 0 __weight = 0 __sound = 0 def __init__(self, name, height, weight, sound): self.__name = name self.__height = height self.__weight = weight self.__sound = sound def set_name(self,name): self.__name = name def get_name(self): return self.__name def get_height(self): return str(self.__height) def get_weight(self): return str(self.__weight) def get_sound(self): return str(self.__sound) def get_type(self): print("Animal") def toStirng(self): return "{} is {} cm tall and {} kilograms and say {}".format(self.__name, self.__height, self.__weight, self.__sound) cat = Animal("Whiskers",33, 10, 'Meow') print(cat.toStirng()) class Dog(Animal): __owner = "" def __init__(self, name, height, weight, sound, owner): #나머지 name~ sound는 super class인 Animal 핸들러에서 처리 self.__owner = owner super(Dog,self).__init__(name,height,weight,sound) def set_owner(self,owner): self.set_owner = owner def get_owner(self): return self.__owner def get_type(self): print("Dog") def toStirng(self): return super(Dog,self).toStirng() + " His/Her owner is {}".format(self.__owner) #how_many 옵션이 없어도 ok def muliple_sounds(self, how_many=None): if how_many is None: pirnt(self.get_sound()) else: print(self.get_sound * how_many) spot = Dog("Spot", 53, 27, "Ruff", "Dreak") print(spot.toStirng()) | cs |
LIST
'기타[etc]' 카테고리의 다른 글
[퍼옴] gdb 분석 보조 - python (0) | 2018.03.24 |
---|---|
QEMU 네트워크 브릿지 구성 (6) | 2018.03.13 |
[Volatility] Profile 만들기 (0) | 2017.07.22 |
[PYTHON] bruteforce (0) | 2017.07.09 |
[Forensic] 17.7.5 교육 내용 정리 (0) | 2017.07.05 |