상속 연습

송용진·2023년 8월 8일
0

알고리즘

목록 보기
156/173
class Animal():
  def walk(self):
    print("걷는다")
  def eat(self):
    print("먹는다")
    
class Human(Animal):
  def wave(self):
    print("손을 흔든다")

class Dog(Animal):
  def wag(self):
    print("꼬리를 흔든다")

#인스턴스를 만든다.
person = Human()

person.walk()
person.eat()
person.wave()

dog = Dog()

dog.walk()
dog.eat()
dog.wave()
profile
백엔드 개발자

0개의 댓글