Hi,
class PropertiesAndPrivateMembers:
def __init__(self, sqftprice, sqft, landarea, landareaprice):
self.set_values(sqftprice, sqft, landarea, landareaprice)
def set_values(self, value, size, plotsize, plotvalue):
if size < 0:
raise ValueError("Size cant be less than 0")
else:
self.__sqft = size
if value < 0:
raise ValueError("Price cant be negative")
else:
self.__sqftprice = value
if plotsize < 0:
raise ValueError("plotsize cant be negative")
else:
self.__landarea = plotsize
if plotvalue < 0:
raise ValueError("plotsize cant be negative")
else:
self.__landareaprice = plotvalue
def calculate(self):
total_construction_cost = ((self.__sqft *
self.__sqftprice) + (self.__landarea * self.__landareaprice))
print("The total Construction Cost is:" + str(total_construction_cost))
papm = PropertiesAndPrivateMembers(2000, 1850, 1200, 4400)
papm1 = PropertiesAndPrivateMembers(2000, 1850, 1500, 4400)
papm.calculate()
papm1.calculate()
I am only setting the value here. I believe this should be sufficient for this particular program. if you are setting the instance attribute using the setter method, what is the use of the getter method?
Thankyou for your help
Thanks
Dhaya