note
description: "[
SHAPE extended with convexity query and a mutable position in space.
Due to once("object") there is one-to-one relation between
any SHAPE object, and an EXTENDED_SHAPE object.
So not only we can externally add new features to an object, but
also object attributes (position in this example).
]"
author: "Miguel Oliveira e Silva"
date: "2024-02-13"
once("object") class EXTENDED_SHAPE(s: SHAPE)
inherit
SHAPE
redefine default_create, out end
feature
default_create
do
create position.make(0,0) -- default position in space
end
perimeter: REAL_64
do
Result := s.perimeter
end
out: STRING
do
Result := "["+generator+"]: "+s.out + ", " + "is_convex="+is_convex.out + ", " + "position="+position.out
end
is_convex: BOOLEAN
do
Result := true --default (redefine if shape might not be convex!)
end
position: VECTOR
move(pos: VECTOR)
do
position := position + pos;
end
end -- EXTENDED_SHAPE