ATM Python
ATM Python
def __init__(self):
self.accounts = {
self.current_account = None
account = self.accounts.get(account_number)
self.current_account = account_number
return True
return False
def account_balance_inquiry(self):
if self.current_account:
return self.accounts[self.current_account]['balance']
if self.current_account:
account = self.accounts[self.current_account]
account['balance'] -= amount
account['history'].append(f"Withdrew ${amount}")
else:
if self.current_account:
account = self.accounts[self.current_account]
account['balance'] += amount
account['history'].append(f"Deposited ${amount}")
if self.current_account:
account = self.accounts[self.current_account]
if account['pin'] == old_pin:
account['pin'] = new_pin
account['history'].append("Changed PIN")
else:
def transaction_history(self):
if self.current_account:
return self.accounts[self.current_account]['history']
def main():
atm = ATM()
print("\n1. Login")
print("2. Exit")
if choice == '1':
if atm.authenticate(account_number, pin):
print("Login successful!")
while True:
print("\nATM Menu:")
print("6. Logout")
if action == '1':
print(atm.cash_withdrawal(amount))
print(atm.cash_deposit(amount))
print(atm.pin_change(old_pin, new_pin))
elif action == '5':
history = atm.transaction_history()
print("Transaction History:")
print(record)
print("Logging out...")
atm.current_account = None
break
else:
else:
print("Exiting...")
break
else:
if __name__ == "__main__":
main()