Skip to content

Commit 47ac569

Browse files
committed
still working on
1 parent a6fed2d commit 47ac569

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

code/Andy/python/andy_lab10_atm_v1.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ def check_balance(self): # going into self to retrieve balance from what you hav
1212

1313
def deposit(self, amount):
1414
self.balance += amount
15-
15+
16+
def check_withdrawal(self, amount): #using self to get balance and amount since thats what we're checking
17+
if self.balance >= amount:
18+
return True
19+
else:
20+
return False
21+
1622

1723

1824
# atm = ATM(5, .001) #putting the values for the initializer.its an object
@@ -36,13 +42,13 @@ def deposit(self, amount):
3642
amount = float(input('How much would you like to deposit? '))
3743
atm.deposit(amount) # call the deposit(amount) method
3844
print(f'Deposited ${amount}')
39-
# elif command == 'withdraw':
40-
# amount = float(input('How much would you like '))
41-
# if atm.check_withdrawal(amount): # call the check_withdrawal(amount) method
42-
# atm.withdraw(amount) # call the withdraw(amount) method
43-
# print(f'Withdrew ${amount}')
44-
# else:
45-
# print('Insufficient funds')
45+
elif command == 'withdraw':
46+
amount = float(input('How much would you like '))
47+
if atm.check_withdrawal(amount): # call the check_withdrawal(amount) method
48+
atm.withdraw(amount) # call the withdraw(amount) method
49+
print(f'Withdrew ${amount}')
50+
else:
51+
print('Insufficient funds')
4652
# elif command == 'interest':
4753
# amount = atm.calc_interest() # call the calc_interest() method
4854
# atm.deposit(amount)

0 commit comments

Comments
 (0)