From 50b9a9447550a57c7b58bd27328cc73ed7a4ee48 Mon Sep 17 00:00:00 2001
From: Sepehr Bayat <bayats1@mcmaster.ca>
Date: Mon, 29 Jan 2018 07:24:28 -0500
Subject: [PATCH] Update TriangleADT.py

---
 Tutorials/T04-A2Example/src/TriangleADT.py | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/Tutorials/T04-A2Example/src/TriangleADT.py b/Tutorials/T04-A2Example/src/TriangleADT.py
index 0d86fcc4..d000799a 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")
 
-- 
GitLab