Created
February 12, 2017 04:26
-
-
Save PyroLagus/150e69ff775e22d101f3a4328c5950ad 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
function Point(x, y) { | |
this.x = x; | |
this.y = y; | |
} | |
Point.prototype = { | |
west: function() { | |
return new this(this.x-1, this.y); | |
}, | |
east: function() { | |
return new this(this.x+1, this.y); | |
}, | |
north: function() { | |
return new this(this.x, this.y-1); | |
}, | |
south: function() { | |
return new this(this.x, this.y+1); | |
}, | |
moveWest: function() { | |
this.x--; | |
}, | |
moveEast: function() { | |
this.x++; | |
}, | |
moveNorth: function() { | |
this.y--; | |
}, | |
moveSouth: function() { | |
this.y++; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment