Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- accounts = []
- name = ""
- class bank:
- def __init__(self, name):
- self.balance = 50
- self.name = name
- print(self.name)
- def getName(self):
- return self.name
- def getBalance(self):
- return self.balance
- def withdrawl(self, amount):
- self.balance -= amount
- def deposit(self, amount):
- self.balance += amount
- def user_login():
- name = input("What is your name? ")
- for i in range(0,len(accounts)-1):
- if (name == accounts[i]):
- print("Invalid input")
- user_login()
- return 0
- name = bank(name)
- accounts.append(name)
- print("Logged in as ",name.getName())
- menu(name)
- def menu(name):
- while 1:
- selection = int(input("What would you like? \n\
- 1. Withdrawl \n\
- 2. Depositt \n\
- 3. View current balance \n\
- 4. Logout"))
- if (selection==1):
- amount = int(input("How much would you like to withdrawl? Current balance is £"+str(name.getBalance())))
- if (amount > name.getBalance()):
- print("Error cannot withdrawl more than ",name.getBalance())
- menu(name)
- return 0
- else:
- name.withdrawl(amount)
- print("New balance is £"+str(name.getBalance()))
- elif (selection == 2):
- amount = int(input("How much would you like to deposit? Current balance is £"+str(name.getBalance())))
- name.deposit(amount)
- print("New balance is £"+str(name.getBalance()))
- elif (selection == 3):
- print("Current balance is £",name.getBalance())
- elif (selection == 4):
- name = ""
- user_login()
- return 0
- user_login()
Advertisement
Add Comment
Please, Sign In to add comment