Code a program that simulates an automatic teller machine


Problem

Code a program that simulates an automatic teller machine (ATM). Since you probably don't have access to a card reader, have the initial screen ask for user ID and a PIN. The user ID will be used to look up teh information for the user's accounts (including the PIN to see whether it matches what the user types). Each user will have access to a checking account and a savings account. The user should be able to check balances, withdraw cach, and transfer money between accounts. Design your interface to be similar to what you see on your local ATM. The user account information should be stored in a file when the program terminates. This file is read in again when the program restarts.

Here's some starter code:

import csv
class Account:
def __init__(self, username, pass, savings, checking):
self.username = username
self.pass = pass
self.savings = savings
self.checking = checking
class Database:
def __init__(self, filename):
self.filename = filename
self.accounts = []
self.readFile()
def readFile():
self.accounts = []
#Read in accounts in a for loop from file
with open(self.file, 'r') as file:
reader = csv.reader(file)
for row in reader:
account = Account(row[0], row[1], row[2], row[3])
self.accounts.append(account)
def saveFile():
#Save account info to file.
with open(self.file, 'w') as file:
writer = csv.writer(file)
for account in self.accounts:
writer.writerow([account.username, account.pass, account.savings, account.checking])
class ATM:
def __init__(self, interface, filename):
self.database = Database(filename)
self.interface = interface
print('Welcome to Fake Bank.')
def run(self):
#Main event loop for the appp will be located
#Make calls to the interface
username, password = self.interface.getCredentials()
class TextInterface:
def __init__(self):
print('Welcome to Fake Bank.')
def getCredentials(self):
input('Please enter your username and password.')
username = input('Username: ')
pass = input('Password: ')
return username, password

def addMoney():
pass

def withdrawMoney():
pass

def transferMoney():
pass

if __name__ == '__main__':
interface = TextInterface()
atm = ATM(interface, 'accounts.txt')
atm.run()

Request for Solution File

Ask an Expert for Answer!!
Python Programming: Code a program that simulates an automatic teller machine
Reference No:- TGS03323558

Expected delivery within 24 Hours