상속
class Person:
def __init__(self,name,age):
self.name = name
self.age = age
def say_hello(self,to_name):
print("안녕!" + to_name + "나는" + self.name)
def introduce(self):
print("내이름은 " + self.name + "그리고 나이는" + str(self.age))
class Police(Person): # 상속할떄 이렇게 넣어 준다. Person 함수 다 사용 가능..
def arrest ( self, to_arrest):
print("넌 체포됐어"+ to_arrest)
class Programmer(Person):
def program(self, to_program):
print("다음에는 뭘 만들지?" + to_program)
chars = Person("워니",20)
jenny = Police("제니",21)
michael = Programmer("마이클",22)
jenny.introduce()
michael.introduce()
jenny.arrest("종민")
michael.program("앱")
#내이름은 제니 그리고 나이는 21
#내 이름은 마이클 그리고 나이는 22
#넌 체포됐어종민
#다음에는 뭘 만들지? 앱