from dataclasses import dataclass from typing import Protocol class BankAccount: def __init__(self, initial_balance: int = 0) -> None: self._balance = initial_balance @property def balance(self) -> int: return self._balance def deposit(self, amount: int) -> None: raise NotImplementedError("Dodaj amount do _balance (odrzuć <= 0 przez ValueError)") def withdraw(self, amount: int) -> bool: raise NotImplementedError("Wypłać jeśli _balance >= amount i zwróć True, inaczej False") class Notifier(Protocol): def format_message(self, msg: str) -> str: ... @dataclass(frozen=True) class EmailNotifier: address: str def format_message(self, msg: str) -> str: raise NotImplementedError("Zwróć '[email] '") @dataclass(frozen=True) class SmsNotifier: phone: str def format_message(self, msg: str) -> str: raise NotImplementedError("Zwróć '[sms] '") class AlertService: def __init__(self, notifiers: list[Notifier]) -> None: self._notifiers = notifiers def broadcast(self, msg: str) -> list[str]: raise NotImplementedError("Wywołaj format_message(msg) dla każdego notifiera")