Polymorphism: Difference between revisions

Content added Content deleted
(Added Prolog)
Line 1,333: Line 1,333:
c.x //Evaluates to 12</lang>
c.x //Evaluates to 12</lang>
=={{header|Elena}}==
=={{header|Elena}}==
ELENA 4.x :
ELENA 5.0 :
<lang elena>import extensions;
<lang elena>import extensions;
Line 1,341: Line 1,341:
prop int Y;
prop int Y;
constructor(int x, int y)
constructor new(int x, int y)
{
{
X := x;
X := x;
Line 1,347: Line 1,347:
}
}
constructor()
constructor new()
<= (0,0);
<= new(0,0);
print() { console.printLine("Point") }
print() { console.printLine("Point") }
Line 1,357: Line 1,357:
prop int R;
prop int R;
constructor()
constructor new()
<= (0);
<= new(0);
constructor(int r)
constructor new(int r)
<= (0, 0, r);
<= new(0, 0, r);
constructor(int x, int y, int r)
constructor new(int x, int y, int r)
<= (x, y)
<= new(x, y)
{
{
R := r
R := r
Line 1,374: Line 1,374:
public program()
public program()
{
{
Point p := new Point();
Point p := Point.new();
Point c := new Circle();
Point c := Circle.new();
p.print();
p.print();