다중 상속
이 연습 문제에서는 Smartphone이라는 새 클래스를 만들어 다중 상속을 구현해 볼 거예요.
아래에는 Smartphone 클래스를 만들 때 사용될 Computer와 Telephone 클래스 정의가 있어요. 두 클래스를 모두 꼼꼼히 살펴보세요!
class Computer:
def __init__(self, brand):
self.brand = brand
def browse_internet(self):
print(f"Using {self.brand}'s default internet browser.")
class Telephone:
def __init__(self, phone_number):
self.phone_number = phone_number
def make_call(self, recipient):
print(f"Calling {recipient} from {self.phone_number}")
이 연습은 강의의 일부입니다
Python 중급 객체 지향 프로그래밍
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Define a Smartphone class that inherits from Computer and
# Telephone, and takes parameters brand, phone_number, and
# music_app
class ____(____, ____):
def __init__(self, ____, ____, ____):
# Call the contructor for the Computer and Telephone
# class, define the music_app instance-level attribute
____.__init__(self, brand)
Telephone.__init__(self, ____)
self.music_app = ____