chore: initialize containerized Python learning workbook (2026 DevOps/SRE)
This commit is contained in:
commit
ae4c421815
63 files changed
+1273
No files matched your search
@@ -0,0 +1,45 @@
|
||||
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] <msg>'")
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SmsNotifier:
|
||||
phone: str
|
||||
|
||||
def format_message(self, msg: str) -> str:
|
||||
raise NotImplementedError("Zwróć '[sms] <msg>'")
|
||||
|
||||
|
||||
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")
|
||||
Reference in new issue
Block a user