forked from jamesbrownlow/class-object-for-loans
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexampleInheritance.py
More file actions
66 lines (50 loc) · 1.82 KB
/
Copy pathexampleInheritance.py
File metadata and controls
66 lines (50 loc) · 1.82 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
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 13 16:06:08 2021
@author: 16617
"""
class finance(object):
''' financial stats of instance '''
def __init__(self, name):
self._name = name
print('name: {}'.format(self._name))
def who(self):
''' docstring to show name associated with instance '''
print(self._name)
def setIncome(self, income):
self._income = income
print('income: {}'.format(income))
def setHausPmt(self, pmt):
self._hausPmt = pmt
print('house pmt: {}'.format(pmt))
def setTaxRate(self, taxRate):
''' tax rate in percent '''
self._taxRate = taxRate/100
print('{}%'.format(taxRate))
print(self._taxRate)
class loan(finance):
''' sub class of finance '''
def __init__(self, name):
super().__init__(name)
def setPV(self, PV):
''' set pV.. must be dollars '''
self._PV = PV
print('present value = ', self._PV)
def setRate(self, ratePct):
''' set interest rate, percent
must be in to interest, apr
'''
self._ratePct = ratePct
print('APR = ', self._ratePct,'%')
def setMonths(self, months):
''' set months to repay, usually an integer '''
self._months = months
print(self._months, 'months')
def computePmt(self):
''' formula: pmt = PV*(r*(1+r)**n)/((1+r)**months -1)'''
r = self._ratePct/100/12 # convert % to a decimal/month
self._Pmt = r*self._PV/(1-(1+r)**(-self._months))
print('payment = $', round(self._Pmt,2))
return self._Pmt
def totalAmtPaid(self, ratePct, months, PV):
pass