Question: A right-angle triangle can be represented by two points: one at the top, and one at the bottom of the triangle (the two points at

 A right-angle triangle can be represented by two points: one at

the top, and one at the bottom of the triangle (the two

A right-angle triangle can be represented by two points: one at the top, and one at the bottom of the triangle (the two points at the diagonal). Given the following Point class, implement the class RATriangle based on the UML diagram: 1. Implement all methods and constructors shown in the UML diagram. 2. The area of a triangle is 0.5 base*height. The base and height can be calculated using the given points. 3. TWO RATriangle objects are equal if they have the same top and bottom points. RATriangle -top: Point -bottom: Point +RATriangle I + RATRiangle(Point, Point) ||+RATRiangle (RATRiangle) +area(): double + equals(RATriangle):boolean top (-2, 4) public class Point { private double x,y: public Point(double x, double y) { this.x = x; this.y = y; } public Point(Point other){ this(other.x,other.y); public double getX() { return x; } public void setX(double x) { this.x = x;} public double getY() { return y;} public void setY(double y) { this.y = y;} public static double distance(Point p1, Point P2{ return Math.sqrt(Math.pow(p1.x-p2.x, 2) + Math.pow(p1.y-p2.y,2)); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!