rover.py 1.06 KB
class Rover(object):
    """
    This Mars Rover should keep track of its current position, its heading, and
    the size of the grid
    """
    def __init__(self, start, route, boundaries):
        b = boundaries.split()
        self.boundaries = [[0, 0], [0, 0]]
        # we may want to do some type checking and data format validation here
        self.boundaries[1][0] = int(b[0])
        self.boundaries[1][1] = int(b[1])

        s = start.split()
        # also, some type checking, and see if the coordinates fit in the
        # boundaries
        self.coordinates = [int(s[0]), int(s[1])]
        # check if the provided heading actually exists
        self.heading = s[2]
        print self.coordinates, self.heading


    # some convenient properties to access the boundaries lists
    @property
    def min_x(self):
        return self.boundaries[0][0]

    @property
    def min_y(self):
        return self.boundaries[0][1]

    @property
    def max_x(self):
        return self.boundaries[1][0]

    @property
    def max_y(self):
        return self.boundaries[1][1]