RosettaCodeData/Task/Polymorphism/Elena/polymorphism.elena

47 lines
627 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
import extensions;
class Point
{
2023-12-16 21:33:55 -08:00
int X : prop;
int Y : prop;
2023-07-01 11:58:00 -04:00
constructor new(int x, int y)
{
X := x;
Y := y
}
constructor new()
<= new(0,0);
print() { console.printLine("Point") }
}
class Circle : Point
{
2023-12-16 21:33:55 -08:00
int R : prop;
2023-07-01 11:58:00 -04:00
constructor new()
<= new(0);
constructor new(int r)
<= new(0, 0, r);
constructor new(int x, int y, int r)
2023-12-16 21:33:55 -08:00
<= super new(x, y)
2023-07-01 11:58:00 -04:00
{
R := r
}
2026-02-01 16:33:20 -08:00
print() { Console.printLine("Circle") }
2023-07-01 11:58:00 -04:00
}
public program()
{
Point p := Point.new();
Point c := Circle.new();
p.print();
c.print()
}