diff --git a/Tutorials/T04-A2Example/src/TriangleADT.py b/Tutorials/T04-A2Example/src/TriangleADT.py index 0d86fcc425e6f2db9e84c5b6a49f1c7dbd610537..d000799a38e544449e075a9f9e19ffa0e5714032 100644 --- a/Tutorials/T04-A2Example/src/TriangleADT.py +++ b/Tutorials/T04-A2Example/src/TriangleADT.py @@ -19,20 +19,21 @@ class Triangle: self.__a = p1 self.__b = p2 self.__c = p3 + self.seq = [0,0,0] self.sides() ## @brief Gets the sides # @return The sides of the triangle def sides(self): - self.AB = pointT.dist(self.__b,self.__b) - self.AC = pointT.dist(self.__a,self.__c) - self.BC = pointT.dist(self.__b,self.__c) + self.seq[0] = pointT.dist(self.__b,self.__b) + self.seq[1] = pointT.dist(self.__a,self.__c) + self.seq[2] = pointT.dist(self.__b,self.__c) ## @brief Inequality theorem # @return the existence of a triangle def inequality_theorem(self): self.sides() - if (self.AB +self.AC > self.BC and self.AB+self.BC > self.AC and self.AC+self.BC >self.AB): + if (self.seq[0] +self.seq[1] > self.seq[2] and self.seq[0]+self.seq[2] > self.seq[1] and self.seq[1]+self.seq[2] >self.seq[1]): return True; elif (self.__a.xcoord()==self.__b.xcoord()==self.__c.xcoord() or self.__a.ycoord()==self.__b.ycoord()==self.__c.ycoord()): return False; @@ -43,7 +44,7 @@ class Triangle: # @return the perimeter of the triangle def perimeter_of_triangle(self): if self.inequality_theorem(): - return self.AB+self.AC+self.BC + return self.seq[0]+self.seq[1]+self.seq[2] else: print("You can't have a triangle with the points") @@ -51,8 +52,8 @@ class Triangle: # @return the area of the triangle def area_of_triangle(self): if self.inequality_theorem(): - P = (self.AB+self.AC+self.BC)/2 - return sqrt(P*(P-self.AB)*(P-self.AC)*(P-self.BC)) + P = (self.seq[0]+self.seq[1]+self.seq[2])/2 + return sqrt(P*(P-self.seq[0])*(P-self.seq[1])*(P-self.seq[2])) else: print("You can't have a triangle with the points")