Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- import time
- class BankAccount(object):
- #class for bank account
- def __init__(self):
- self.username = ''
- self.userpassword = ''
- self.pinnum = ''
- self.balance = 0
- def Menu():
- print('----------------------------------------------')
- print('Menu:')
- menu = input('[1] View Account Details\n[2] Deposit Money\n[3] Withdraw Money\n[4] Transaction History\n[5] Quit\nEnter: ')
- if (menu == '1'):
- print('----------------------------------------------')
- print('Username: ',cus.username,'\nPassword: ',cus.password,'\nCard Number: ',cus.cardnum,'\nPin Number: ',cus.pin,'\nCurrent Balance: ',cus.balance)
- input('\nPress Enter to continue...')
- time.sleep(1)
- Menu()
- if (menu == '2'):
- Addmoney()
- if (menu == '3'):
- Removemoney()
- if (menu == '4'):
- history()
- if (menu == '5'):
- quit()
- def Bank():
- print('Welcome to ARC Bank')
- print('----------------------------------------------')
- prompt = input('[1] Open a new bank account\n[2] Quit\nEnter: ')
- print('----------------------------------------------')
- if (prompt == '1'):
- #creates a new customer
- cus.username = input('Choose your username: ')
- cus.password = input('Choose your password: ')
- cus.pin = randint(1000, 9999)
- cus.cardnum = randint(1000000000000000, 9999999999999999)
- print('Your assigned card number is:',cus.cardnum)
- print('Your assigned pin is:',cus.pin)
- Menu()
- elif (prompt == '2'):
- #checks for existing customer
- quit()
- else:
- print('Invalid entry, please try again\n\n')
- Bank()
- def Addmoney():
- #add some money
- addedamount = int(input('Deposit Amount: '))
- if (addedamount == '1'):
- pass
- #add it all
- cus.balance +=addedamount
- print('You added', "$" + str(addedamount),'dollars was added\nIt now contains',"$" + str(cus.balance))
- Menu()
- def Removemoney():
- #add some money
- removedamount = int(input('Remove Amount: '))
- #add it all
- cus.balance -=removedamount
- print('You removed', "$" + str(removedamount),'dollars was added\nIt now contains',"$" + str(cus.balance))
- #open the file for storing the current account's transaction history
- file = open('history.txt','a')
- #write something into the file
- file.write('Attempt to withdraw money from the account from an ATM.')
- #close the file
- file.close()
- Menu()
- def history():
- #show transaction history
- #access the external storage
- thefile = open('history.txt','r')
- #go and get everything as a LIST
- stuff = thefile.readlines()
- #done with the file
- thefile.close()
- #see what we got
- print(stuff)
- cus = BankAccount()
- Bank()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement