-->
class Point
atom x, y
function Point(object x, atom y=0)
if Point(x) then
this.x = x.x
this.y = x.y
else
this.x = x
this.y = y
end if
return this
end function
function get_x() return x end function
function get_y() return y end function
procedure set_x(atom x) this.x = x end procedure
procedure set_y(atom y) this.y = y end procedure
procedure show()
printf(1,"point (%g,%g)\n",{x,y})
end procedure
end class
class Circle extends Point
atom r
function Circle(object x, atom y=0, r=0)
if Circle(x) then
this.x = x.x
this.y = x.y
this.r = x.r
elsif Point(x) then
r = y -- assume r got passed in y
this.x = x.x
this.y = x.y
this.r = r
else
this.x = x
this.y = y
this.r = r
end if
return this
end function
function get_r() return r end function
procedure set_r(atom r) this.r = r end procedure
procedure show()
printf(1,"circle (%g,%g,%g)\n",{x,y,r})
end procedure
end class
Point p1 = new({4,5}),
p2 = new({p1})
p1.y = 7
Circle c1 = new({p1,9}),
c2 = new({c1}),
c3 = new({10,11,12})
c1.r = 8
p1.show()
p2.show()
c1.show()
c2.show()
c3.show()