Skip to content

Implement apply_interest() in bank.py#138

Draft
hummusonrails wants to merge 1 commit into
ADG-VITV:mainfrom
hummusonrails:codex/apply-interest
Draft

Implement apply_interest() in bank.py#138
hummusonrails wants to merge 1 commit into
ADG-VITV:mainfrom
hummusonrails:codex/apply-interest

Conversation

@hummusonrails

Copy link
Copy Markdown

Summary

Implements Account.apply_interest() in bank.py.

The method now:

  • rejects negative interest rates without changing account state
  • calculates interest as a percentage of the current balance
  • adds the computed interest to the account balance
  • records the interest transaction as (\"Interest\", interest)
  • returns True when interest is applied successfully

Validation

python3 - <<'PY'
from bank import Account

acct = Account('A1', 'Ada', 100.0)
assert acct.apply_interest(5) is True
assert acct.balance == 105.0
assert acct.transactions == [('Interest', 5.0)]
assert acct.apply_interest(0) is True
assert acct.balance == 105.0
assert acct.transactions[-1] == ('Interest', 0.0)
assert acct.apply_interest(-1) is False
assert acct.balance == 105.0
print('apply_interest checks passed')
PY

Result: apply_interest checks passed

Closes #35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement apply_interest() in bank.py

1 participant