Advertisement
Guest User

Untitled

a guest
Mar 15th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.88 KB | None | 0 0
  1. from random import randint
  2. import time
  3.  
  4. class BankAccount(object):
  5.     #class for bank account
  6.     def __init__(self):
  7.         self.username = ''
  8.         self.userpassword = ''
  9.         self.pinnum = ''
  10.         self.balance = 0
  11.  
  12. def Menu():
  13.     print('----------------------------------------------')
  14.     print('Menu:')
  15.     menu = input('[1] View Account Details\n[2] Deposit Money\n[3] Withdraw Money\n[4] Transaction History\n[5] Quit\nEnter: ')
  16.  
  17.     if (menu == '1'):
  18.         print('----------------------------------------------')
  19.         print('Username: ',cus.username,'\nPassword: ',cus.password,'\nCard Number: ',cus.cardnum,'\nPin Number: ',cus.pin,'\nCurrent Balance: ',cus.balance)
  20.         input('\nPress Enter to continue...')
  21.         time.sleep(1)
  22.         Menu()
  23.     if (menu == '2'):
  24.         Addmoney()
  25.     if (menu == '3'):
  26.         Removemoney()
  27.  
  28.     if (menu == '4'):
  29.         history()
  30.     if (menu == '5'):
  31.         quit()
  32.    
  33.    
  34.  
  35. def Bank():
  36.     print('Welcome to ARC Bank')
  37.     print('----------------------------------------------')
  38.     prompt = input('[1] Open a new bank account\n[2] Quit\nEnter: ')
  39.     print('----------------------------------------------')
  40.  
  41.     if (prompt == '1'):
  42.         #creates a new customer
  43.         cus.username = input('Choose your username: ')
  44.         cus.password = input('Choose your password: ')
  45.         cus.pin = randint(1000, 9999)
  46.         cus.cardnum = randint(1000000000000000, 9999999999999999)
  47.         print('Your assigned card number is:',cus.cardnum)
  48.         print('Your assigned pin is:',cus.pin)
  49.         Menu()
  50.        
  51.     elif (prompt == '2'):
  52.         #checks for existing customer
  53.         quit()
  54.     else:
  55.         print('Invalid entry, please try again\n\n')
  56.         Bank()
  57.  
  58. def Addmoney():
  59.     #add some money
  60.     addedamount = int(input('Deposit Amount: '))
  61.     if (addedamount == '1'):
  62.         pass
  63.     #add it all
  64.     cus.balance +=addedamount
  65.     print('You added', "$" + str(addedamount),'dollars was added\nIt now contains',"$" + str(cus.balance))
  66.     Menu()
  67.  
  68. def Removemoney():
  69.     #add some money
  70.     removedamount = int(input('Remove Amount: '))
  71.     #add it all
  72.     cus.balance -=removedamount
  73.     print('You removed', "$" + str(removedamount),'dollars was added\nIt now contains',"$" + str(cus.balance))
  74.     #open the file for storing the current account's transaction history
  75.     file = open('history.txt','a')
  76.     #write something into the file
  77.     file.write('Attempt to withdraw money from the account from an ATM.')
  78.     #close the file
  79.     file.close()
  80.     Menu()
  81.  
  82. def history():
  83.     #show transaction history
  84.     #access the external storage
  85.     thefile = open('history.txt','r')
  86.     #go and get everything as a LIST
  87.     stuff = thefile.readlines()
  88.     #done with the file
  89.     thefile.close()
  90.     #see what we got
  91.     print(stuff)
  92.  
  93.        
  94. cus = BankAccount()
  95. Bank()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement