Skip to content

Commit 7555695

Browse files
Saved file resulting in a 'change'
1 parent e123316 commit 7555695

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

code/zach/lab10-atm.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,31 @@ def __init__(self, balance=0, interest_rate=0.001):
1010
def check_balance(self):
1111
"""Returns the account balance."""
1212
self.transactions.append({'Date': datetime.now().strftime(
13-
"%Y-%m-%d %H:%M:%S"), 'transaction_type': 'Checked Balance', 'balance': self.balance})
13+
"%Y-%m-%d %H:%M:%S"), 'transaction_type': 'checked balance', 'balance': self.balance})
1414
return self.balance
1515

1616
def deposit(self, amount):
1717
"""Deposits the given amount in the account."""
1818
previous_balance = self.balance
1919
self.balance += amount
20-
self.transactions.append({'Date': datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'transaction_type': 'Deposit',
20+
self.transactions.append({'Date': datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'transaction_type': 'deposit',
2121
'amount': amount, 'previous_balance': previous_balance, 'new_balance': self.balance})
2222
return self.balance
2323

2424
def check_withdrawal(self, amount):
2525
"""Returns true if the withdrawn amount won't put the account in the negative"""
26-
return self.balance - amount >= 0
26+
if self.balance - amount >= 0:
27+
return True
28+
else:
29+
self.transactions.append({'date': datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'transaction_type': 'Withdrawal', 'result': 'insufficient funds',
30+
'amount': amount, 'balance': self.balance})
31+
return False
2732

2833
def withdraw(self, amount):
2934
"""Withdraws the amount from the account and returns it."""
3035
previous_balance = self.balance
3136
self.balance -= amount
32-
self.transactions.append({'Date': datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'transaction_type': 'Withdrawal',
37+
self.transactions.append({'date': datetime.now().strftime("%Y-%m-%d %H:%M:%S"), 'transaction_type': 'Withdrawal',
3338
'amount': amount, 'previous_balance': previous_balance, 'new_balance': self.balance})
3439
return self.balance
3540

0 commit comments

Comments
 (0)