Last active
November 30, 2015 13:27
-
-
Save kbparagua/acb44fa439d0ef377874 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 Pacman | |
def self.get_instance | |
# instantiate the singleton instance if it is not existing yet. | |
if @instance.nil? | |
@instance = Pacman.new | |
end | |
@instance | |
end | |
def initialize x, y | |
@x = x | |
@y = y | |
end | |
def move_up | |
@y = @y + 1 | |
end | |
def move_down | |
@y = @y - 1 | |
end | |
def move_right | |
@x = @x + 1 | |
end | |
def move_left | |
@x = @x - 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment