#!/usr/bin/env python class Location(object): """Track and update a location on a 2-D grid. Assume origin (0, 0) is located in the center of the grid. Moving right increases the x value and moving up increases the y value. """ def __init__(self): # Set starting location to the origin. self.x = 0 self.y = 0 def move_up(self): self.y += 1 def move_down(self): raise Exception("TODO.") def move_left(self): raise Exception("TODO.") def move_right(self): raise Exception("TODO.") def jump_to(self, x, y): raise Exception("TODO.") def get_x_location(self): return self.x def get_y_location(self): raise Exception("TODO.") if __name__ == '__main__': loc = Location() loc.move_up() loc.move_up() loc.move_left() loc.move_left() loc.move_down() loc.move_right() loc.jump_to(1, 1) loc.move_up() loc.move_right() loc.move_down() loc.move_down() loc.move_down() loc.move_right() print "Final position is: ", loc.get_x_location(), loc.get_y_location()