/
spirzen
/
it-code-examples
Обзор
Документация
Войти
/
spirzen
/
it-code-examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/python/code-407-113-007/main.py
23 строки
556 B
Spirzen
Code migration pack
09 июн 2026, 01:41
09 июн 2026, 01:41
cebc284
Код
Авторство
О чём код?
# Python (хороший пример) from abc import ABC, abstractmethod class Discount(ABC): @abstractmethod def apply(self, amount): pass class SeasonalDiscount(Discount): def apply(self, amount): return amount * 0.9 class VipDiscount(Discount): def apply(self, amount): return amount * 0.8 class PromoDiscount(Discount): def apply(self, amount): return amount * 0.85 def calculate_total(items, discount: Discount): total = sum(item.price for item in items) return discount.apply(total)