@@ -12,7 +12,13 @@ def check_balance(self): # going into self to retrieve balance from what you hav
12
12
13
13
def deposit (self , amount ):
14
14
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
+
16
22
17
23
18
24
# atm = ATM(5, .001) #putting the values for the initializer.its an object
@@ -36,13 +42,13 @@ def deposit(self, amount):
36
42
amount = float (input ('How much would you like to deposit? ' ))
37
43
atm .deposit (amount ) # call the deposit(amount) method
38
44
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' )
46
52
# elif command == 'interest':
47
53
# amount = atm.calc_interest() # call the calc_interest() method
48
54
# atm.deposit(amount)
0 commit comments