diff options
author | uvok | 2025-04-14 20:36:12 +0200 |
---|---|---|
committer | uvok | 2025-04-14 20:36:12 +0200 |
commit | 14b737dc629950a4d9fe30c841c8697c958feff0 (patch) | |
tree | 1a0d6c374272498d74607c50757ee7a015ea58ca /trade.py | |
parent | 71f5ca16725d5e75edae7b1db876b5ec277fd797 (diff) |
Check initializer
Diffstat (limited to 'trade.py')
-rw-r--r-- | trade.py | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -1,5 +1,10 @@ +from decimal import Decimal + class Trade: def __init__(self, amount: float, total_cost: float, date: str) -> None: + if amount <= 0 or total_cost <= 0: + raise ValueError("Amount and total cost must be > 0") + self.__amount: float = amount self.__total_cost: float = total_cost self.__date: str = date |