Created
June 18, 2012 18:54
-
-
Save Poincare/2950025 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Robot | |
def initialize | |
@coordinates = [0, 0] | |
@fired_at = [] | |
end | |
def forward(n) | |
@coordinates[0] += n | |
end | |
def backward(n) | |
@coordinates[0] -= n | |
end | |
def right(n) | |
@coordinates[1] += n | |
end | |
def left(n) | |
@coordinates[1] -= n | |
end | |
def fire | |
@fired_at.push(@coordinates) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment