-
-
Save jileidan/8699f1211cad75e9352a2155369f7a04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ATM: | |
def __init__(self, money, bank_name): | |
self.money = money | |
self.bank_name = bank_name | |
self.withdrawals_list = [] | |
def withdraw(self,request): | |
result = self.money | |
if request > self.money: | |
print('money not enigh') | |
elif request <= 0: | |
print('plz try again') | |
else: | |
self.withdrawals_list.append(request) | |
self.money -= request | |
notes = [100, 50, 10, 5] | |
for note in notes: | |
while request >= note: | |
request -= note | |
print("give ", str(note),'$') | |
if request < 5 and request > 0: | |
print("give " , str(request),'$') | |
request = 0 | |
return result | |
def show_withdrawals(self): | |
for withdrawal in self.withdrawals_list: | |
print(withdrawal) | |
money1 = 1000 | |
money2 = 1000 | |
atm1 = ATM(money1,'CAC bank') | |
atm2 = ATM(money2,'YICT bank') | |
print('CAC bank:'),atm1.withdraw(250) | |
print('CAC bank:'),atm1.withdraw(153) | |
print('YICT bank:'),atm2.withdraw(400) | |
print('YICT bank:'),atm2.withdraw(313) | |
print('withdrawal:') | |
atm1.show_withdrawals() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment