Enhance the Point class by adding a public instance method Equals(), which takes an Object as argument and hence overrides the equals() in Object. Model your Equals() after the ones in String and Circle.
Specifically, your equals() returns true if the Object argument has actual type Point and is in the same location as the instance Point, i.e., they have equal x-components and have equal y-components. Otherwise it returns false.
Add a Triangle class, extending GeometricObject, with the following components.
Three private Point data fields p1, p2, and p3.
A constructor taking three Point's as arguments. This constructor throws but does NOT catch an exception if any two of the points are equal (use the Equals() method from part 1.)
A constructor taking two Points's as arguments. This constructor creates the third point with x-component the same as the first point's x-component and y-component the same as the second point's y-component. (This triangle is a right triangle, but you can ignore that.)
A constructor with no arguments that constructs the triangle with points (0,0), (0,1), and (1,0). (This triangle is also a right triangle, but you can ignore that). This standard triangle has area 1/2 as you will be verifying in part 3.
All triangles are colored green.
A public perimeter() instance method.
A public area() instance method. The formula is below and is the one we used for quadrilaterals.
A public instance method isEqualArea(), which takes a triangle as argument. It returns true if the instance triangle and the argument triangle have equal area (use the area() method from part 2G.
A public class method highest() taking no arguments that returns the triangle that is the highest. That is, the triangle whose largest y-value is the largest.
Rename the TestQuad class TestGeometry to better reflect what it does.
Add to TestGeometrya (weird) static method called isEqualAreaTriangleQuadrilateral(). This method has two parameters, the first is a Triangle and the second is aQuadrilateral. The method returns true if the two arguments have equal area.
Extend the main() method to test all the features you added.
In particular have main() catch the exception thrown by the first Triangle constructor and use instead the third (standard) constructor, which we know cannot throw an exception.. Test both the case where the exception is thrown and the case where the exception is not thrown.
Do not remove any of the existing parts of TestQuad.
Calculating the Area of a Triangle Given the Vertices
Calculate the three side lengths s1, s2, and s3 using the disTo() method in the Point class.
Calculate the perimeter P using the perimeter() method in the Triangle class.
Calculate the semiperimeter S = P/2.
Calculate the area as the square root of the quantity S×(S-s1)×(S-s2)×(S-s3)
A Quadrilateral and Friends (version 3)
There is not much difference between versions 2 and 3
It is not our intention to break the school's academic policy. Projects posted are only used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly fill out the form.
Please provide a valid email address and we'll get back to you in less than 24 hours.
We will be sending an invoice through PayPal upon confirmation.
We are a non profit organization however we need an amount to keep this organization running,
and to be able to complete our research and development.