2022-07-21 16:07:13 -05:00
|
|
|
from abc import abstractmethod
|
|
|
|
from turtle import Turtle
|
|
|
|
|
|
|
|
class BoundedTurtle(Turtle):
|
2022-07-21 16:36:45 -05:00
|
|
|
def __init__(self, speed, x_min, x_max, y_min, y_max):
|
2022-07-21 16:07:13 -05:00
|
|
|
super().__init__()
|
2022-07-21 16:36:45 -05:00
|
|
|
self.__x_min = x_min
|
|
|
|
self.__x_max = x_max
|
|
|
|
self.__y_min = y_min
|
|
|
|
self.__y_max = y_max
|
2022-07-21 16:07:13 -05:00
|
|
|
self.__speed = speed
|
|
|
|
|
2022-07-21 16:36:45 -05:00
|
|
|
def out_of_bounds(self):
|
2022-07-21 16:07:13 -05:00
|
|
|
xPos, yPos = self.position()
|
|
|
|
out = False
|
|
|
|
if xPos < self.__xMin or xPos > self.__xMax:
|
|
|
|
out = True
|
|
|
|
if yPos < self.__yMin or yPos > self.__yMax:
|
|
|
|
out = True
|
|
|
|
return out
|
|
|
|
|
2022-07-21 16:36:45 -05:00
|
|
|
def below_bottom_bound(self):
|
2022-07-21 16:07:13 -05:00
|
|
|
x_pos, y_pos = self.position()
|
|
|
|
out = False
|
|
|
|
if y_pos < self.__yMin:
|
|
|
|
out = True
|
|
|
|
return out
|
|
|
|
|
2022-07-21 16:36:45 -05:00
|
|
|
def get_speed(self):
|
2022-07-21 16:07:13 -05:00
|
|
|
return self.__speed
|
|
|
|
|
2022-07-21 16:36:45 -05:00
|
|
|
def get_x_min(self):
|
2022-07-21 16:07:13 -05:00
|
|
|
return self.__xMin
|
|
|
|
|
|
|
|
def getXMax(self):
|
|
|
|
return self.__xMax
|
|
|
|
|
|
|
|
def getYMin(self):
|
|
|
|
return self.__yMin
|
|
|
|
|
|
|
|
def getYMax(self):
|
|
|
|
return self.__yMax
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def remove(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
@abstractmethod
|
|
|
|
def move(self):
|
|
|
|
pass
|