Add function to generate random line segments

This commit is contained in:
2020-03-09 18:51:41 +01:00
parent c96c1fc8bc
commit 978bb9b789

View File

@@ -1,6 +1,7 @@
#!/usr/bin/python3
"""The linesegment module defines the class line_segment."""
import random
import point
class LineSegment:
@@ -34,3 +35,8 @@ class LineSegment:
return self.__startpoint.str() + "-->" + self.__endpoint.str()
def draw(self):
"""TODO: Draw the line segment in a canvas."""
def get_random(min_x=0, max_x=100, min_y=0, max_y=100):
"""Set the point to a random place inside the boundaries"""
return LineSegment(point.Point(random.randint(min_x, max_x), random.randint(min_y, max_y)), \
point.Point(random.randint(min_x, max_x), random.randint(min_y, max_y)))