Project: Taxicab

Write a class called Taxicab with three private data members: the cab's x-coordinate, its y-coordinate, and its odometer reading.

Here is how the class could be used:

cab = Taxicab(3, -8)       # creates a Taxicab object at coordinates (3, -8)
cab.move_x(4)              # moves cab 4 units "right"
cab.move_y(-5)             # moves cab 5 units "down"
cab.move_x(-2)             # moves cab 2 units "left"
print(cab.get_odometer())  # prints the current odometer reading

Save the file as Taxicab.py.

Show a solution

Try the project on your own first. This is one working solution, followed by its tests. Press Run to run the tests. Read them to see what thorough testing looks like, then change the solution and run again to watch a test fail.

Projects run on your own computer, so you tell us when you are done.