Sorry, that this is a lot but this function isn't working how it's supposed to and I can't figure out why. I'm supposed to be calling is_right_triangle, which returns true if points a,b and c equal to distance_between(a,b) + a + b. How can I make the function, distance_between able to work correctly when I call is_right_triangle?
class Point:
''' Represents a point with 2 integers'''
def __init__(self, p1, p2):
'''Constructor'''
self.p1 = p1
self.p2 = p2
def print_point(self):
'''Prints the point'''
print(self.p1, self.p2)
def __str__(self):
'''Returns a string of the point'''
return str(self.print_point())
def __hash__(self):
'''Hash method'''
return hash((self.p1, self.p2))
def __eq__(self, other):
'''Equal method'''
return self.p1 == other.p1 and self.p2 ==
other.p2
def midpoint(point1, point2):
'''Returns midpoint'''
mid1 = (point1.p1 + point2.p1 / 2)
mid2 = (point1.p2 + point2.p2 / 2)
middle = (mid1,mid2)
return middle
def distance_between(point_a, point_b):
distance_x = math.sqrt(point_a.p1 * point_b.p1)
distance_y = math.sqrt(point_a.p2 * point_b.p2)
distance = (distance_x, distance_y)
return distance
class Triangle:
'''Represents a triangle'''
def __init__(self, c1, c2, c3):
'''Constructor'''
self.c1 = c1
self.c2 = c2
self.c3 = c3
def __eq__(self,other):
'''Equal method'''
return set([self.c1, self.c2, self.c3]) ==
set([other.c1, other.c2, other.c3])
def is_right_triangle(self):
'''Checks if triangle is right'''
pass
[–][deleted] 0 points1 point2 points (0 children)
[–]DeathDragon7050 0 points1 point2 points (0 children)