"""
Exercise 1: a BankAccount class with dunder methods

Implement class BankAccount with:
  __init__(self, owner, balance=0)
  deposit(self, amount)     -> adds amount, returns new balance (raise
                               ValueError if amount <= 0)
  withdraw(self, amount)    -> subtracts amount, returns new balance
                               (raise ValueError if amount <= 0 or
                               amount > balance)
  __repr__(self)             -> "BankAccount(owner='NAME', balance=N)"
  __eq__(self, other)         -> True if same owner AND same balance
  __lt__(self, other)          -> compares by balance
"""

class BankAccount:
    def __init__(self, owner, balance=0):
        # TODO
        pass

    def deposit(self, amount):
        # TODO
        pass

    def withdraw(self, amount):
        # TODO
        pass

    def __repr__(self):
        # TODO
        pass

    def __eq__(self, other):
        # TODO
        pass

    def __lt__(self, other):
        # TODO
        pass


# --- self-check: do not modify below this line ---
acc = BankAccount("Ana", 100)
acc.deposit(50)
acc.withdraw(30)

checks = []
checks.append((acc.balance if hasattr(acc, "balance") else None, 120))
checks.append((repr(acc), "BankAccount(owner='Ana', balance=120)"))
checks.append((acc == BankAccount("Ana", 120), True))
checks.append((acc == BankAccount("Bob", 120), False))
checks.append((BankAccount("X", 10) < BankAccount("Y", 20), True))

try:
    acc.withdraw(10_000)
    over_withdraw_raised = False
except ValueError:
    over_withdraw_raised = True
checks.append((over_withdraw_raised, True))

try:
    acc.deposit(-5)
    negative_deposit_raised = False
except ValueError:
    negative_deposit_raised = True
checks.append((negative_deposit_raised, True))

all_passed = all(actual == expected for actual, expected in checks)
for actual, expected in checks:
    print(f"got {actual!r}, expected {expected!r} -> {'PASS' if actual == expected else 'FAIL'}")

print("ALL PASS" if all_passed else "SOME FAILED")
