redef var x: N
redef var y: N
-
- init(x, y: N)
- do
- self.x = x
- self.y = y
- end
end
# An abstract 3d point, strongly linked to its implementation `Point3d`
super Point[N]
redef var z: N
-
- init(x, y, z: N)
- do
- super
- self.z = z
- end
end
# An abstract 2d line segment
interface ILine[N: Numeric]
+ # The type of points that ends the segment
type P: IPoint[N]
+ # The point that is the left-end of the segment
fun point_left: P is abstract
+
+ # The point that is the right-end of the segment
fun point_right: P is abstract
redef fun to_s do return "{point_left}--{point_right}"
redef var point_left: P
redef var point_right: P
- init(a, b: P)
+ init
do
- if a.x < b.x then
- point_left = a
- point_right = b
- else
+ var a = point_left
+ var b = point_right
+ if a.x > b.x then
point_left = b
point_right = a
end