RosettaCodeData/Task/Polymorphism/Arturo/polymorphism.arturo

31 lines
510 B
Text
Raw Permalink Normal View History

2026-02-01 16:33:20 -08:00
define :point [
init: method [x :floating, y :floating][
this\x: x
this\y: y
2023-07-01 11:58:00 -04:00
]
2026-02-01 16:33:20 -08:00
string: method [][
2023-07-01 11:58:00 -04:00
render "point (x: |this\x|, y: |this\y|)"
]
]
2026-02-01 16:33:20 -08:00
define :circle [
init: method [center :point, radius :floating][
this\center: center
this\radius: radius
2023-07-01 11:58:00 -04:00
]
2026-02-01 16:33:20 -08:00
string: method [][
2023-07-01 11:58:00 -04:00
render "circle (center: |this\center|, radius: |this\radius|)"
]
]
p: to :point [10.0, 20.0]
c: to :circle @[p, 10.0]
inspect p
inspect c
print p
print c