class Dog:
vaccine = 'covid19'
def __init__(self, dogname, dogage):
self.name = dogname
self.age = dogage
def info(self):
return '{} is {} years old.'.format(self.name, self.age)
def speak(self, sound):
return '{} says {}!'.format(self.name, sound)
# 인스턴스 생성
dog1 = Dog('Happy', 10)
dog2 = Dog('Rafael', 37)
dog3 = Dog('Sunflower', 35)
# method 호출
print(dog1.info())
print(dog1.speak("I'm happy"))
print(dog2.speak("I am Rafael"))
# Happy is 10 years old.
# Happy says I'm happy!
# Rafael says I am Rafael!