From 978bb9b789ca87756fb6eacff73fa0368d367d60 Mon Sep 17 00:00:00 2001 From: Pascal Lais Date: Mon, 9 Mar 2020 18:51:41 +0100 Subject: [PATCH] Add function to generate random line segments --- linesegment.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linesegment.py b/linesegment.py index b7a6538..4c1c8b2 100644 --- a/linesegment.py +++ b/linesegment.py @@ -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)))