Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
60
Task/Polymorphism/Seed7/polymorphism.seed7
Normal file
60
Task/Polymorphism/Seed7/polymorphism.seed7
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
$ include "seed7_05.s7i";
|
||||
|
||||
const type: GraphicObj is new interface;
|
||||
|
||||
const proc: print (in GraphicObj: aGraphicObj) is DYNAMIC;
|
||||
|
||||
|
||||
const type: Point is new struct
|
||||
var integer: x is 0;
|
||||
var integer: y is 0;
|
||||
end struct;
|
||||
|
||||
type_implements_interface(Point, GraphicObj);
|
||||
|
||||
const func Point: Point (in integer: x, in integer: y) is func
|
||||
result
|
||||
var Point: newPoint is Point.value;
|
||||
begin
|
||||
newPoint.x := x;
|
||||
newPoint.y := y;
|
||||
end func;
|
||||
|
||||
const proc: print (in Point: aPoint) is func
|
||||
begin
|
||||
writeln("Point(" <& aPoint.x <& ", " <& aPoint.y <& ")");
|
||||
end func;
|
||||
|
||||
|
||||
const type: Circle is sub Point struct
|
||||
var integer: r is 0;
|
||||
end struct;
|
||||
|
||||
type_implements_interface(Circle, GraphicObj);
|
||||
|
||||
const func Circle: Circle (in integer: x, in integer: y, in integer: r) is func
|
||||
result
|
||||
var Circle: newCircle is Circle.value;
|
||||
begin
|
||||
newCircle.x := x;
|
||||
newCircle.y := y;
|
||||
newCircle.r := r;
|
||||
end func;
|
||||
|
||||
const proc: print (in Circle: aCircle) is func
|
||||
begin
|
||||
writeln("Circle(" <& aCircle.x <& ", " <& aCircle.y <& ", " <& aCircle.r <& ")");
|
||||
end func;
|
||||
|
||||
|
||||
const proc: main is func
|
||||
local
|
||||
var Point: pnt is Point(1, 2);
|
||||
var Circle: circ is Circle(3, 4, 5);
|
||||
var GraphicObj: graph is Point.value;
|
||||
begin
|
||||
graph := pnt;
|
||||
print(graph);
|
||||
graph := circ;
|
||||
print(graph);
|
||||
end func;
|
||||
Loading…
Add table
Add a link
Reference in a new issue