In class, we designed and implemented the Point class. Included in the Point class are accessor and mutator methods. We also implemented distanceTo()
method that calculated and returned the distance between two instances of type Point.
The Circle class was completed in Recitations 2 and 3. In Recitation 3, you designed a Circle class that uses Point objects to locate a circle. In addition, you implemented contains()
, which determines if an instance of Point is inside the circle, and intersects()
, which determines if two circles intersect.
The Rectangle class was completed in class as an example of objects that refer to other objects. The Rectangle class included a contains()
method that determined if an instance of type Point is in the rectangle and an intersect()
method that determines if two rectangles intersect.
A left-half bounding box of a circle is the SMALLEST Rectangle whose sides are parallel to the x and y axes of the coordinate space and can completely contain the circle. Figure 1 below shows an instance of Circle of radius r that is located at (xc, yc) with a left-half bounding box located at (xr, yr) = (xc - r, yc - r), width w = r, and height h = 2 * r.
Figure 1: A circle with its left-half bounding box rectangleYour task is to implement the getLeftBoundingBox()
method. The method returns an instance of a Rectangle (Rectangle object) that is the left-half bounding box of the circle on which it was invoked. For example,
Circle c = new Circle(new Point(15,10), 10);
Rectangle rect = c.getLeftBoundingBox();
The rectangle rect
should be a Rectangle object located at (5,0) with a width of 10 and a height of 20.
A test is provided with the IntelliJ project. Create a Gradle run configuration and use the test to complete your implementation of getLeftBoundingBox()
. When you are ready to submit, use the CodeGrade link to submit your solution.