Created
January 1, 2011 21:05
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
#!/usr/bin/lua | |
do | |
POINT = {} | |
POINT.new = function(pnt, x, y) | |
local pt = {} | |
function pt.display(pnt, comment) | |
print(comment) | |
print(x) | |
print(y) | |
print("") | |
end | |
function pt.getX(pnt) | |
return x | |
end | |
function pt.getY(pnt) | |
return y | |
end | |
function pt.setX(pnt,newX) | |
x = newX | |
end | |
function pt.setY(pnt,newY) | |
y = newY | |
end | |
return pt | |
end | |
end | |
pul = POINT:new(1,1) | |
plr = POINT:new(80,25) | |
print(type(pul)) | |
pul:display("Upper left.") | |
plr:display("Lower right.") -- This fails if you uncomment it | |
pul:setX(2000) | |
pul:display("Upper left after strongarm.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment