Bachstelze
April 20th, 2011, 04:45 PM
This has been puzzling me for days, hopefully someone can help me with this. :p
So I have an interface named Point2D, which represents a point in two dimensions, implemented by a class named Point2DCartesien that implements a point using cartesian coordinates. Amon other methods, Point2D specifies an equals() method to check whether a point is equal to another. I have a program named TestPoint2DCartesien, which shows me that my equals() method works as intended.
Now I have an interface named Triangle, which represents a triangle as an array of three Point2D's, implemented by a class named TriangleDef. It also specifies an equals() method, to check whether two triangles are equal. I have a TestTriangle program to check it, and that's where things go wild.
The problem : I want to use the equals() method of Point2D to check whether all the points in the array of a Triangle are equal to those in the array of another Triangle. However, when I call the equals() method of Point2D from inside the equals() method of Triangle, it always returns false and I have absolutely no idea which code is actually run, because a println I have there is not called.
Code attached, any help would be greatly appreciated.
So I have an interface named Point2D, which represents a point in two dimensions, implemented by a class named Point2DCartesien that implements a point using cartesian coordinates. Amon other methods, Point2D specifies an equals() method to check whether a point is equal to another. I have a program named TestPoint2DCartesien, which shows me that my equals() method works as intended.
Now I have an interface named Triangle, which represents a triangle as an array of three Point2D's, implemented by a class named TriangleDef. It also specifies an equals() method, to check whether two triangles are equal. I have a TestTriangle program to check it, and that's where things go wild.
The problem : I want to use the equals() method of Point2D to check whether all the points in the array of a Triangle are equal to those in the array of another Triangle. However, when I call the equals() method of Point2D from inside the equals() method of Triangle, it always returns false and I have absolutely no idea which code is actually run, because a println I have there is not called.
Code attached, any help would be greatly appreciated.