This is a program I am working on for homework and I keep getting this error and I'm not sure what I can do to fix it. Any help would be greatly appreciated.
here is the error:
Traceback (most recent call last):
File "C:\Users\crazyjdog\Desktop\School Stuff\CSET 1100\Programs and Charts\program121.py", line 86, in <module>
main()
File "C:\Users\crazyjdog\Desktop\School Stuff\CSET 1100\Programs and Charts\program121.py", line 80, in main
tri.setArea(side1, side2, side3)
File "C:\Users\crazyjdog\Desktop\School Stuff\CSET 1100\Programs and Charts\program121.py", line 56, in setArea
area = sqrt(s(s-side1)(s-side2)(s-side3))
TypeError: 'float' object is not callable
this is the code for the program:
from math import *
class GeometricObject():
def __init__(self, color = "green", filled = True):
self.__color = color
self.__filled = filled
def getColor(self):
return self.__color
def setColor(self, color):
self.__color = color
def isFilled(self):
return self.__filled
def setFilled(self, filled):
self.__filled = filled
def __str__(self):
return "color: " + self.__color + \
" and filled: " + str(self.__filled)
class Triangle(GeometricObject):
def __init__(self, side1 = 1, side2 = 1, side3 = 1):
super().__init__()
self.__side1 = float(side1)
self.__side2 = float(side2)
self.__side3 = float(side3)
def getSide1(self):
return self.__side1
def setSide1(self, side1):
self.__side1 = side1
def getSide2(self):
return self.__side2
def setSide2(self, side2):
self.__side2 = side2
def getSide3(self):
return self.__side3
def setSide3(self, side3):
self.__side3 = side3
def getArea(self):
return self.__area
def setArea(self, side1, side2, side3):
s = (side1 + side2 + side3)/2
area = sqrt(s(s-side1)(s-side2)(s-side3))
self.__area = area
def getPerimeter(self):
return self.__perimeter
def setPerimeter(side1, side2, side3):
perimeter = side1 + side2 + side3
self.__perimeter = perimeter
def __str__(self):
return "Triangle: " + "side 1 = " + str(self.__side1)+ " " +\
"side 2 = " + str(self.__side2) + " " + \
"side 3 = " + str(self.__side3)
def main():
side1 = eval(input("Enter a value for side 1: "))
side2 = eval(input("Now enter a value for side 2: "))
side3 = eval(input("Now enter a value for side 3: "))
color = input("Enter the color of the triangle: ")
filled = input("Enter 1(filled) or 0(not filled) " + \
" for the triangle being filled: ")
tri = Triangle(side1, side2, side3)
print("\n\n")
print("A Triangle ", tri.__str__())
print("The area is: ", tri.getArea())
print("The perimeter is: ", tri.getPerimeter())
main()