In [21]:
class House(object):
"""
An example for the migration of a family, living in the 21st century,
relocating between Bangalore and Chennai.
"""
def __init__(self, bhk, dwellType, stayPeriod, rentAmt, doorNum, city):
self._slogan = "IT capital"
self._country = "India"
self.bhk = bhk
self.dwellType = dwellType
self.stayPeriod = stayPeriod
self.rentAmt = rentAmt
self.doorNum = doorNum
self.city = city
def calcRent(self):
if self.stayPeriod >= 1:
totalRent = (self.stayPeriod * 12) * self.rentAmt
else:
totalRent = self.stayPeriod * self.rentAmt
smry = "In %s, the %s of %s, while staying at %d which was a %d BHK house, you paid %-5d as rental for %d years" %(self.city, self._slogan, self._country, self.doorNum, self.bhk, totalRent, self.stayPeriod)
return smry
# def ownself(self):
#amb = House(2, own, 5, 0)
#mgpr = House(2, own, 4, 0)
blr_1146 = House(2, "rent", 2, 7000, 1146, "BLR")
print blr_1146.calcRent()
blr_1313 = House(2, "rent", 1, 10000, 1313, "BLR")
print blr_1313.calcRent()
blr_1033 = House(1, "rent", 1, 5000, 1033, "BLR")
print blr_1033.calcRent()
blr_936 = House(2, "rent", 2.5, 16000, 936, "BLR")
print blr_936.calcRent()
blr_937 = House(2, "rent", 1.5, 20000, 937, "BLR")
print blr_937.calcRent()
print "\n" + blr_937.city + ",",
print "the " + blr_937._slogan + " of",
print blr_937._country
blr_1143 = House(3, "own", 0.7, 0, 1143, "BLR")
In [ ]: