We have a collection of possibly overlapping 45 degree isosceles right triangles.
Each triangle is oriented with its hypotenuse at the bottom, parallel with the
x axis. Each triangle is specified by giving the center point (xCenter,yCenter)
of its hypotenuse and the height. For example, a triangle with center at (1,3) and with height 7
would have its three vertices at (-6,3), (8,3), and (1,10).
We need to know the area that is covered by the collection of triangles. Of
course, we don't want to count overlapping areas multiple times. Create a
class TriArea that contains a method area that is given int[]s xCenter, yCenter,
and height and returns the area covered. The specification of the i-th
triangle is given by the i-th element of xCenter,
yCenter, and height.
|