Untitled
3 years ago in Python
#banking system
class User:
def __init__(self,name,gender,age,amountOfMoney):
self.name = name
self.age = age
self.gender = gender
self.amountOfMoney = amountOfMoney
def showDetails(self):
print('Your account name is',self.name , 'You are',self.age, 'years old ')
print('You are',self.gender)
print('You have £',self.amountOfMoney)
def deposit(self):
amountToAdd = int(input('Please enter how much money you would like to add'))
x = self.amountOfMoney + amountToAdd
print('You have £',x)
def withdraw(self):
amountToWithdraw = int(input('Please enter how much you would like to remove'))
x = self.amountOfMoney - amountToWithdraw
if x > 0:
print('You have withdrawn', amountToWithdraw, 'Your balance is now',self.amountOfMoney)
else:
print('Not enough money in account')
if __name__ == '__main__':
uname = User
print('What would you like to do: \n'
'1. Check account details \n '
'2. Withdraw money from your account \n '
' ' ' 3. Deposit money into your account\n ')
choice = input('Please select a number')
if choice == '1':
uname.showDetails()
elif choice == '2':
uname.withdraw()
elif choice== '3':
uname.deposit()