Task

Create two classes   Point(x,y)   and   Circle(x,y,r)   with a polymorphic function print, accessors for (x,y,r), copy constructor, assignment and destructor and every possible default constructors




type point(object o)
    return sequence(o) and length(o)=2 and atom(o[1]) and atom(o[2])
end type
 
function new_point(atom x=0, atom y=0)
    return {x,y}
end function
 
type circle(object o)
    return sequence(o) and length(o)=2 and point(o[1]) and atom(o[2])
end type
 
function new_circle(object x=0, atom y=0, atom r=0)
    if point(x) then
        r = y           -- assume r got passed in y
        return {x,r}    -- {point,r}
    end if
    return {{x,y},r}    -- {point,r}
    -- (or {new_point(x,y),r} if you prefer)
end function
 
point p = new_point(4,5)
circle c1 = new_circle(p,6),
       c2 = new_circle(4,5,6}
?c1
?c2
