Advertisement
Guest User

Simple ATM

a guest
Jan 24th, 2014
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.59 KB | None | 0 0
  1. inscribedCustomers = {}
  2.  
  3. class Customers(dict):
  4.     def __init__(self, name, password, balance):
  5.         self.name = name
  6.         self.password = password
  7.         self.balance = balance
  8.  
  9.     def tell(self):
  10.         return self.name
  11.  
  12.     def tell_password(self):
  13.         return self.password
  14.  
  15.     def tell_balance(self):
  16.         return self.balance
  17.  
  18.  
  19. def add(person):
  20.     inscribedCustomers[person.tell()] = [person.tell_password(), person.tell_balance()]
  21.  
  22.  
  23. def delete(person):
  24.     del inscribedCustomers[person]
  25.  
  26.  
  27. def check_balance():
  28.     check_name = str(raw_input('\nName: '))
  29.     if check_name in inscribedCustomers:
  30.         print "\nWelcome %s it's good to see you again" % check_name
  31.         check_password = str(raw_input('\nEnter password: '))
  32.         if check_password in inscribedCustomers[check_name]:
  33.             print '\nYour balance is %s.\n' % inscribedCustomers[check_name][1]
  34.  
  35.  
  36. def register():
  37.     enter_name = raw_input('\nEnter name: ')
  38.     enter_password = raw_input('\nEnter password: ')
  39.     reenter_password = raw_input('Reenter password: ')
  40.     if enter_password == reenter_password:
  41.         input_balance = int(raw_input("\nEnter how much you'd like to deposit (USD): "))
  42.         print '\n'
  43.         result = Customers(enter_name, reenter_password, input_balance)
  44.         add(result)
  45.     else:
  46.         print "%s your passwords must match in order to register." % enter_name
  47.         return
  48.  
  49.  
  50. def main():
  51.     print 'Welcome to Trusty SP. ' \
  52.           'We desire to make your banking easier.' \
  53.  
  54.     input_main = raw_input('What would you like to do?\n\n'
  55.                            '1. Register\n'
  56.                            '2. Check Balance\n'
  57.                            '3. Delete Account\n\n'
  58.                            'Enter Choice: ')
  59.  
  60.     if input_main == '1' or input_main == 'Register' or input_main == 'register':
  61.         register()
  62.         main()
  63.  
  64.     elif input_main == '2' or input_main == 'Check Balance' or input_main == 'check balance':
  65.         check_balance()
  66.         main()
  67.  
  68.     elif input_main == '3' or input_main == 'Delete Account' or input_main == 'delete account':
  69.         delete_name = raw_input('\nName: ')
  70.         if delete_name in inscribedCustomers:
  71.             delete_password = raw_input('Password: ')
  72.             if delete_password in inscribedCustomers[delete_name]:
  73.                 print '\n%s your account will be delete and your funds of %d will be returned.\n' \
  74.                                             % (delete_name, inscribedCustomers[delete_name][1])
  75.  
  76.                 assure_delete = raw_input("Are you sure you want to delete?\n"
  77.                                       "\n1. Yes"
  78.                                       "\n2. No, I changed my mind."
  79.                                       "\n>> ")
  80.  
  81.                 if assure_delete == '1' or assure_delete == 'Yes':
  82.                     delete(delete_name)
  83.                     main()
  84.                 elif assure_delete == '2' or assure_delete == 'No':
  85.                     print '\nReturning to main screen.\n\n'
  86.                     main()
  87.     else:
  88.         print 'We would appreciate your comments, please write below.\n'
  89.         comments = raw_input('Comments: \n')
  90.         for i in comments:
  91.             if i == 'I':
  92.                 reply = comments.replace('I', 'Master Chief')
  93.                 print reply
  94.                 print '\nYou done messed up A-Aron.'
  95.  
  96.  
  97.  
  98. if __name__ == '__main__':
  99.     try:
  100.         main()
  101.  
  102.     except KeyboardInterrupt:
  103.         print 'Returning...'
  104.         main()
  105.     except ValueError:
  106.         print 'Invalid entry'
  107.         main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement