logancberrypie

Untitled

Mar 6th, 2017
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1.  
  2.  
  3. accounts = []
  4. name = ""
  5.  
  6. class bank:
  7.  
  8. def __init__(self, name):
  9. self.balance = 50
  10. self.name = name
  11. print(self.name)
  12.  
  13.  
  14. def getName(self):
  15. return self.name
  16.  
  17. def getBalance(self):
  18. return self.balance
  19.  
  20. def withdrawl(self, amount):
  21. self.balance -= amount
  22.  
  23. def deposit(self, amount):
  24. self.balance += amount
  25.  
  26. def user_login():
  27. name = input("What is your name? ")
  28. for i in range(0,len(accounts)-1):
  29. if (name == accounts[i]):
  30. print("Invalid input")
  31. user_login()
  32. return 0
  33. name = bank(name)
  34. accounts.append(name)
  35. print("Logged in as ",name.getName())
  36. menu(name)
  37.  
  38.  
  39.  
  40. def menu(name):
  41. while 1:
  42. selection = int(input("What would you like? \n\
  43. 1. Withdrawl \n\
  44. 2. Depositt \n\
  45. 3. View current balance \n\
  46. 4. Logout"))
  47. if (selection==1):
  48. amount = int(input("How much would you like to withdrawl? Current balance is £"+str(name.getBalance())))
  49. if (amount > name.getBalance()):
  50. print("Error cannot withdrawl more than ",name.getBalance())
  51. menu(name)
  52. return 0
  53. else:
  54. name.withdrawl(amount)
  55. print("New balance is £"+str(name.getBalance()))
  56. elif (selection == 2):
  57. amount = int(input("How much would you like to deposit? Current balance is £"+str(name.getBalance())))
  58. name.deposit(amount)
  59. print("New balance is £"+str(name.getBalance()))
  60. elif (selection == 3):
  61. print("Current balance is £",name.getBalance())
  62. elif (selection == 4):
  63. name = ""
  64. user_login()
  65. return 0
  66.  
  67. user_login()
Advertisement
Add Comment
Please, Sign In to add comment