-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
83 lines (71 loc) · 2.92 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
transactions = {}
class BankAccount:
def __init__(self,account_number, holder_name, password):
self.account_number = account_number
self.holder_name = holder_name
self.password = password
self.balance = 0.0
def deposit(self, amount):
if amount > 0:
self.balance += amount
BankTransaction.add_transaction(self.account_number,['Deposited', amount])
print('Amount deposited.')
else:
'Invalid input!'
def withdraw(self, amount):
if amount > 0 and amount <= self.balance:
self.balance -= amount
BankTransaction.add_transaction(self.account_number,['Withdrew', amount])
print('Amount withdrawn.')
elif amount > self.balance:
print('Insufficient! funds')
else:
print('Invalid input!')
def show_info(self):
return f'Account number : {self.account_number} \nHolder name : {self.holder_name} \nBalance : {self.balance}'
class BankSystem:
def __init__(self):
self.accounts = {}
def create_account(self, account_number, holder_name, password):
if account_number not in self.accounts:
self.accounts[account_number] = BankSystem(account_number, holder_name, password)
BankTransaction.add_account(account_number)
print('Account created successfully')
else:
return 'Account already exists!.'
def login(self, account_number, password):
account_number = int(input('Enter your account number : '))
password = input('Enter your password : ')
account = self.accounts.get(account_number)
if account and account.password == password:
print('Login Successfull!')
else:
return 'Invalid! account number or password.'
class BankTransaction:
@staticmethod
def add_account(account_number):
if account_number not in transactions:
transactions[account_number] = []
else:
print('Account already exists')
@staticmethod
def add_transaction(accout_number, details):
if accout_number in transactions:
temp = transactions[accout_number]
temp.append(details)
transactions[accout_number] = temp
else:
print('No Transaction found!.')
def main():
bank_system = BankSystem()
while True:
print('-'*15,'\nWelcome to Banking System','-'*15)
print('1.')
print('2.')
print('3.')
choice = input('Enter your choice : ')
if choice == '1':
account_number = int(input('Enter your account number : '))
holder_name = input('Enter your name : ')
password = input('Enter your password : ')
BankAccount.create_account(account_number, holder_name, password)