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




 
class Point {
   var x
   var y
   new(ax, ay) {
       this.x = ax
       this.y = ay
   }
   new(point) {
        this(point.x, point.y)
   }
   method getX() { return x }
   method setX(newX) { x = newX }
 
   method getY() { return y }
   method setY(newY) { y = newY }
 
   method print() {
       console.println("Point")
   }
}
 
class Circle extends Point {
   var r
 
   new() { this(0,0,0) }
   new(point, aR) { super(point) ; r = aR }
   new(aX, aY, aR) { super(aX, aY); r = aR }
 
   method getR() { return r }
   method setR(newR) { r = newR }
 
   method print() {
       console.println("Circle")
   }
 
}
 
program polymorphism {
    val p = new Point()
    val c = new Circle()
    p.print()
    c.print()
}
 