Add function to generate random line segments
This commit is contained in:
@@ -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)))
|
||||
|
||||
Reference in New Issue
Block a user