-
Notifications
You must be signed in to change notification settings - Fork 0
/
#OOPR-Prac-6
96 lines (81 loc) · 2.83 KB
/
#OOPR-Prac-6
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
84
85
86
87
88
89
90
91
92
93
94
95
96
class Loan:
__loan_counter = 1001
def __init__(self):
self.__loan_id=None
self.__loan_amount=None
self.__interest_rate=None
def generate_loan_id(self):
Loan.__loan_counter+=1
self.__loan_id=Loan.__loan_counter
def calculate_amount_interest_rate(self,monthly_salary):
pass
def set_loan_amount(self,loan_amount):
self.__loan_amount=loan_amount
def set_interest_rate(self,interest_rate):
self.__interest_rate=interest_rate
def get_loan_id(self):
return self.__loan_id
def get_loan_amount(self):
return self.__loan_amount
def get_interest_rate(self):
return self.__interest_rate
class HomeLoan(Loan):
def __init__(self):
super().__init__()
self.__points=5
def get_points(self):
return self.__points
def calculate_amount_interest_rate(self,monthly_salary):
if monthly_salary>=20000:
amount=15*monthly_salary
self.set_loan_amount(amount)
self.set_interest_rate(15)
self.generate_loan_id()
else:
return -1
class PersonalLoan(Loan):
def __init__(self):
super().__init__()
self.__gift_voucher=500
def get_gift_voucher(self):
return self.__gift_voucher
def calculate_amount_interest_rate(self,monthly_salary):
if monthly_salary>=7000:
amount=5*monthly_salary
self.set_loan_amount(amount)
self.set_interest_rate(12)
self.generate_loan_id()
else:
return -1
class Customer:
__customer_id_list=[1,2,3,4,5]
def __init__(self,loan_type, monthly_salary):
self.__customer_id=Customer.__customer_id_list[-1]+1
Customer.__customer_id_list.append(self.__customer_id)
self.__loan_type=loan_type
self.__monthly_salary=monthly_salary
self.__loan=None
def apply_loan(self):
if self.__loan_type=="Home" or self.__loan_type=="Personal":
if self.__loan_type=="Home":
loan_obj=HomeLoan()
loan_obj.calculate_amount_interest_rate(self.__monthly_salary)
self.__loan=loan_obj
else:
loan_obj=PersonalLoan()
loan_obj.calculate_amount_interest_rate(self.__monthly_salary)
self.__loan=loan_obj
def get_customer_id(self):
return self.__customer_id
def get_loan_type(self):
return self.__loan_type
def get_monthly_salary(self):
return self.__monthly_salary
def get_loan(self):
return self.__loan
c=Customer("Home",25000)
c.apply_loan()
x=c.get_loan().get_loan_amount()
print(x)
x=c.get_loan().get_interest_rate()
print(x)