Random coordinates are now float values.
This commit is contained in:
4
point.py
4
point.py
@@ -11,7 +11,7 @@ class Point():
|
|||||||
self.set_y(y)
|
self.set_y(y)
|
||||||
def set_x(self, new_x):
|
def set_x(self, new_x):
|
||||||
"""Set the X-Coordinate of the Point"""
|
"""Set the X-Coordinate of the Point"""
|
||||||
self.__x = int(new_x)
|
self.__x = new_x
|
||||||
def get_x(self):
|
def get_x(self):
|
||||||
"""Returns the X-Coordinate of the Point"""
|
"""Returns the X-Coordinate of the Point"""
|
||||||
return self.__x
|
return self.__x
|
||||||
@@ -29,7 +29,7 @@ class Point():
|
|||||||
|
|
||||||
def get_random(min_x=0, max_x=100, min_y=0, max_y=100):
|
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"""
|
"""Set the point to a random place inside the boundaries"""
|
||||||
return Point(random.randint(min_x, max_x), random.randint(min_y, max_y))
|
return Point(random.uniform(min_x, max_x), random.uniform(min_y, max_y))
|
||||||
|
|
||||||
def sort_set(point_set, sort_by_y=False):
|
def sort_set(point_set, sort_by_y=False):
|
||||||
"""Sort a Point set using merge sort"""
|
"""Sort a Point set using merge sort"""
|
||||||
|
|||||||
Reference in New Issue
Block a user