ABC로 포멀 인터페이스 구현하기
이 연습 문제에서는 ABC 클래스와 @abstractmethod 데코레이터로 만든 포멀 인터페이스를 구현해 보겠습니다. Business 인터페이스는 미리 만들어 두었고, 아래에 보여 드립니다. 화이팅!
class Business(ABC):
@abstractmethod
def sell_product(self, product_name, price, quantity):
pass
이 연습은 강의의 일부입니다
Python 중급 객체 지향 프로그래밍
실습형 인터랙티브 연습
이 예제를 이 샘플 코드를 완성하여 풀어보세요.
# Create a class that inherits the Business interface
class ____(____):
def __init__(self, business_name):
self.business_name = business_name
# Attempt to create a Bakery object, observe the exception
____:
blue_eyed_baker = ____("Blue Eyed Baker")
____ Exception ____ e:
print(____)