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




      INSTALL @lib$ + "CLASSLIB"
 
      REM Create parent class with void 'doprint' method:
      DIM PrintableShape{doprint}
      PROC_class(PrintableShape{})
 
      REM Create derived class for Point:
      DIM Point{x#, y#, setxy, retx, rety, @constructor, @@destructor}
      PROC_inherit(Point{}, PrintableShape{})
      DEF Point.setxy (x,y) : Point.x# = x : Point.y# = y : ENDPROC
      DEF Point.retx = Point.x#
      DEF Point.rety = Point.y#
      DEF Point.@constructor Point.x# = 1.23 : Point.y# = 4.56 : ENDPROC
      DEF Point.@@destructor : ENDPROC
      DEF Point.doprint : PRINT Point.x#, Point.y# : ENDPROC
      PROC_class(Point{})
 
      REM Create derived class for Circle:
      DIM Circle{x#, y#, r#, setxy, setr, retx, rety, retr, @con, @@des}
      PROC_inherit(Circle{}, PrintableShape{})
      DEF Circle.setxy (x,y) : Circle.x# = x : Circle.y# = y : ENDPROC
      DEF Circle.setr (r) : Circle.r# = r : ENDPROC
      DEF Circle.retx = Circle.x#
      DEF Circle.rety = Circle.y#
      DEF Circle.retr = Circle.r#
      DEF Circle.@con Circle.x# = 3.2 : Circle.y# = 6.5 : Circle.r# = 7 : ENDPROC
      DEF Circle.@@des : ENDPROC
      DEF Circle.doprint : PRINT Circle.x#, Circle.y#, Circle.r# : ENDPROC
      PROC_class(Circle{})
 
      REM Test the polymorphic 'doprint' function:
      PROC_new(mypoint{}, Point{})
      PROC(mypoint.doprint)
      PROC_discard(mypoint{})
      PROC_new(mycircle{}, Circle{})
      PROC(mycircle.doprint)
      PROC_discard(mycircle{})
      END