-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbanking_project.py
More file actions
67 lines (55 loc) · 2.47 KB
/
Copy pathbanking_project.py
File metadata and controls
67 lines (55 loc) · 2.47 KB
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
class Bank:
def __init__(self, IFSC_Code, bankname, branchname, loc):
self.IFSC_Code = IFSC_Code
self.bankname = bankname
self.branchname = branchname
self.loc = loc
class Customer:
def __init__(self, CustomerID, custname, address, contactdetails):
self.CustomerID = CustomerID
self.custname = custname
self.address = address
self.contactdetails = contactdetails
class Account(Bank):
def __init__(self, IFSC_Code, bankname, branchname, loc, AccountID, Cust, balance):
super().__init__(IFSC_Code, bankname, branchname, loc)
self.AccountID = AccountID
self.Cust = Cust
self.balance = balance
def getAccountInfo(self):
return f"Account ID: {self.AccountID}\nCustomer Name: {self.Cust.custname}\nBalance: {self.balance}"
def deposit(self, amount, is_cash=True):
if is_cash:
self.balance += amount
return f"Deposited {amount} (cash). New balance: {self.balance}"
else:
return "Non-cash deposits are not supported."
def withdraw(self, amount):
if self.balance >= amount:
self.balance -= amount
return f"Withdrew {amount}. New balance: {self.balance}"
else:
return "Insufficient balance for withdrawal."
def getBalance(self):
return f"Current balance: {self.balance}"
class SavingsAccount(Account):
def __init__(self, IFSC_Code, bankname, branchname, loc, AccountID, Cust, balance, SMinBalance):
super().__init__(IFSC_Code, bankname, branchname, loc, AccountID, Cust, balance)
self.SMinBalance = SMinBalance
def getSavingAccountInfo(self):
return f"Account ID: {self.AccountID}\nCustomer Name: {self.Cust.custname}\nBalance: {self.balance}"
def withdraw(self, amount):
if self.balance - amount >= self.SMinBalance:
self.balance -= amount
return f"Withdrew {amount}. New balance: {self.balance}"
else:
return "Insufficient balance for withdrawal."
if __name__ == "__main__":
# Create a customer
customer1 = Customer(101, "DikshaY", "123 Barra Street", "diksha@gmail.com")
# Create a savings account
savings_account1 = SavingsAccount("ABC123", "SBI", "Kanpur", "Uttar Pradesh", 1001, customer1, 5000, 1000)
print(savings_account1.getAccountInfo())
print(savings_account1.deposit(2000))
print(savings_account1.withdraw(500))
print(savings_account1.getBalance())