|
| 1 | +class Bank: |
| 2 | + def __init__(self,name,accountNo,password): |
| 3 | + self.owner = name |
| 4 | + self.balance = 0.0 |
| 5 | + self.accountNo = accountNo |
| 6 | + self.password = password |
| 7 | + self.log = True |
| 8 | + |
| 9 | + def getBalance(self): |
| 10 | + return self.balance |
| 11 | + |
| 12 | + def control(self,a_no,p): |
| 13 | + if len(p) == 9: |
| 14 | + if a_no == self.accountNo and p == self.password: |
| 15 | + print("Your login has occurred. Welcome...") |
| 16 | + return self.log |
| 17 | + else: |
| 18 | + print("You entered your user name or password incorrectly. Try again...") |
| 19 | + self.log = False |
| 20 | + return self.log |
| 21 | + |
| 22 | + else: |
| 23 | + print("You entered a missing password...") |
| 24 | + |
| 25 | + def deposit(self,amount): |
| 26 | + self.balance+= amount |
| 27 | + |
| 28 | + def withdraw(self,amount): |
| 29 | + if (self.balance < amount ): |
| 30 | + print("\n Insufficient balance!....") |
| 31 | + else: |
| 32 | + self.balance -=amount |
| 33 | + |
| 34 | + |
| 35 | + |
| 36 | +class App : |
| 37 | + def __init__(self): |
| 38 | + self.bank_acc = Bank("Öykü Sıla Şahin","BA12345","123456789") |
| 39 | + |
| 40 | + def check(self,acc_No,psw): |
| 41 | + return self.bank_acc.control(acc_No,psw) |
| 42 | + |
| 43 | + def login(self): |
| 44 | + dongu_girdi = False |
| 45 | + hak = 3 |
| 46 | + while dongu_girdi == False or hak != 0: |
| 47 | + acc_No = input("Please enter your account number: ") |
| 48 | + psw = input("Enter your password: ") |
| 49 | + dongu_girdi = self.check(acc_No, psw) |
| 50 | + if dongu_girdi == False: |
| 51 | + if hak == 0: |
| 52 | + print("You entered the wrong password 3 times. Your card is blocked...") |
| 53 | + hak -= 1 |
| 54 | + else: |
| 55 | + dongu_girdi = True |
| 56 | + self.run() |
| 57 | + |
| 58 | + def run(self): |
| 59 | + print("Please select the defined process...") |
| 60 | + print("1-)Withdrawal\n","2-)Deposit\n","3-)Balance Inquiry\n","4-)Exit") |
| 61 | + dongu = True |
| 62 | + while dongu == True: |
| 63 | + op = int(input("Select and enter the action you want to do from the menu: ")) |
| 64 | + if op == 1: |
| 65 | + print("You have selected the Withdrawal Process..") |
| 66 | + wAmount = float(input("Enter amount to be Withdrawn: ")) |
| 67 | + self.bank_acc.withdraw(wAmount) |
| 68 | + dongu = False |
| 69 | + elif op == 2: |
| 70 | + print("You have selected the Deposit...") |
| 71 | + dAmount = float(input("Enter amount to be Deposited: ")) |
| 72 | + self.bank_acc.deposit(dAmount) |
| 73 | + dongu = False |
| 74 | + elif op == 3: |
| 75 | + print("You have selected Balance Inquiry..") |
| 76 | + print("\n Net Available Balance=",self.bank_acc.getBalance()) |
| 77 | + dongu = False |
| 78 | + elif op == 4: |
| 79 | + print("You have selected the Output Process...") |
| 80 | + print ("Thankyou for using the bank!") |
| 81 | + dongu = False |
| 82 | + exit() |
| 83 | + |
| 84 | + else: |
| 85 | + print("You made an incorrect transaction selection. Please select a valid transaction!!!") |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | +def main(): |
| 90 | + print("Enter your account number and password to log into your bank account...") |
| 91 | + bank = App() |
| 92 | + bank.login() |
| 93 | + |
| 94 | +main() |
0 commit comments