Define a class named RandomRightTriangle that represents right triangles whose sides lie entirely within a given square region. A RandomRightTriangle object should be able to report its vertices as Point objects and draw itself. Use the class LineSegment, as described in the previous exercise, to represent the triangle’s sides. Hint: Define the hypotenuse of the triangle as a LineSegment object whose endpoints are chosen randomly. These end-points are two vertices of the triangle. Let the third vertex be the vertex of the right angle, as you can determine its coordinates from the coordinates of the other two vertices.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here