Ioannis Michailidis wrote:In other words, I need a new SuperTriangle class, hierarchically higher than Polygon, whose contains() will be able not only to traverse normal triangles with vertices with given coordinates, but also SuperTriangles, with fictitious vertices and still return true or false.
Is there an elegant way to do this without having to rewrite contains() from scratch?
Ioannis Michailidis wrote:Well, this point lies in the core of the question. I think that a SuperTriangle with some virtual vertices is a Superclass of a normal triangle and not vice versa. I am afraid if I simply extend Polygon, consequently bad things will happen.
Is there no pattern in which a subclass "becomes" a superclass?
Ioannis Michailidis wrote:The current Polygon class is simply Polygon You are suggesting I should mess with it (how?)