Tell us what’s happening:
i am stuck at step 15. what am i missing out?
discount = PercentageDiscount(10)
discounted_price = discount.apply_discount(product)
print(discounted_price)
Your code so far
# User Editable Region
from abc import ABC, abstractmethod
class Product:
def __init__(self, name: str, price: float) -> None:
self.name = name
self.price = price
def __str__(self) -> str:
return f'{self.name} - ${self.price}'
class DiscountStrategy(ABC):
@abstractmethod
def is_applicable(self, product: Product, user_tier: str) -> bool:
pass
@abstractmethod
def apply_discount(self, product: Product) -> float:
pass
class PercentageDiscount(DiscountStrategy):
def __init__(self, percent: int) -> None:
self.percent = percent
def is_applicable(self, product: Product, user_tier: str) -> bool:
return self.percent <= 70
def apply_discount(self, product: Product) -> float:
return product.price * (1 - self.percent / 100)
product = Product('Wireless Mouse', 50.0)
print(product)
discount = PercentageDiscount(10)
discounted_price = discount.apply_discount(product)
print(discounted_price)
# User Editable Region
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/149.0.0.0 Safari/537.36 Edg/149.0.0.0
Challenge Information:
Build a Discount Calculator - Step 15