How to resolve the algorithm Polymorphism step by step in the Aikido programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Polymorphism step by step in the Aikido programming language

Table of Contents

Problem Statement

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

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Polymorphism step by step in the Aikido programming language

Source code in the aikido programming language

class Point (protected x=0.0, protected y=0.0) {
    public function print {
        println ("Point")
    }

    public function getX { return x }
    public function getY { return y }

    public function setX(nx) { x = nx }
    public function setY(ny) { y = ny }
}

class Circle (x=0.0, y=0.0, r=0.0) extends Point (x, y) {
    public function print {
        println ("Circle")
    }

    public function getR { return r }
    public function setR(nr) { r = nr }
}

var p = new Point (1, 2)
var c = new Circle (1, 2, 3)
p.print()
c.print()

  

You may also check:How to resolve the algorithm Number names step by step in the Nim programming language
You may also check:How to resolve the algorithm Honaker primes step by step in the Sidef programming language
You may also check:How to resolve the algorithm Sieve of Eratosthenes step by step in the Vedit macro language programming language
You may also check:How to resolve the algorithm Averages/Root mean square step by step in the Racket programming language
You may also check:How to resolve the algorithm Anadromes step by step in the Raku programming language