what did I do wrong on line 64? It is just saying if all sides are equal to each other, then return true, right? |
No. The
if (s2 == s3 == s1 == s4)
is equivalent to
1 2 3
|
bool t1 = (s2 == s3);
bool t2 = (t1 == s1); // when is int equal to true/false?
if ((t2 == s4)
|
The order should be x1,y1 x2,y2 x3,y3 x4,y4 |
What does that
mean?
The code sample of
AbstractionAnon seems to assume that:
* (x1,y1) is upper left vertex
* (x2,y2) is upper right vertex
* (x3,y3) is lower left vertex
* (x4,y4) is lower right vertex
When I did create the three example Quadralaterals, I did not follow that convention (by mistake).
More descriptive parameter names would make the purpose of each argument more clear.
The order is crucial, if your calculations involve directionality (as they do). x1-x2 != x2-x1
Indeed. However, X1(1) != X3(2) and Y1(0) != Y2(1) so in your class it is not a square.
how are my computations wrong? |
The code of
AbstractionAnon had comments, explaining each operation. It did compare the lengths of top and bottom horizontal sides.
What was left to you? The lengths of left and right
vertical sides.
(We follow the convention that x-axis is horizontal and y-axis is vertical.)
Do you calculate the left and right using the vertical component of the coordinates?
Using different component than for the top and bottom?
No, you don't. You do use only the x-values.