Question: create a class named Circle that contains fields representing a center point (doubles variables centerX and centerY) and the radius (a double variable radius). Similar
create a class named Circle that contains fields representing a center point (doubles variables centerX and centerY) and the radius (a double variable radius). Similar to the Rectangle class, create a setValues method that sets all values, a setCenter method that only sets the center coordinates, a setRadius method that only sets the radius, and an overlaps method that checks if this circle overlaps another circle. (Two circles overlap when the distance between the center points of the two circles is less than the sum of the radii of the circles; you may need to look up a formula to calculate the distance between two point to use in this function.) In addition, create a class named TestCircle (similar to TestRectangle) that creates three circle objects C1, C2, and C3; choose parameters for the circles so that C1 overlaps C2 and C2 overlaps C3, but C1 does not overlap C3. In the test class, print the results of testing the overlaps between each pair of circles.



setValues(0,0,0,0); } * /** * Initialize rectangle data from coordinates of top-left corner and size. * @param left x-coordinate of top-left corner (left edge) of rectangle * @param top y-coordinate of top-left corner (top edge) of rectangle * @param width width of rectangle @param height height of rectangle */ public Rectangle(double left, double top, double width, double height) { setValues (left, top, width, height); } /** * Set rectangle data. * Used to update game entities that move and/or change size. * @param left x-coordinate of top-left corner (left edge) of rectangle * @param top y-coordinate of top-left corner (top edge) of rectangle * @param width width of rectangle * @param height height of rectangle */ public void setValues (double left, double top, double width, double height) { this. left = left; this.top top; this.width width; this.height = height; this.right = left + width; this.bottom - top + height; } /** * Update rectangle data. * Used for game entities that move. @param left x-coordinate of top-left corner (left edge) of rectangle * @param top y-coordinate of top-left corner (top edge) of rectangle } /** * Update rectangle data. * Used for game entities that move. * @param left x-coordinate of top-left corner (left edge) of rectangle * @param top y-coordinate of top-left corner (top edge) of rectangle public void setPosition(double left, double top) { setValues (left, top, this.width, this.height); } /** * Determine if this rectangle overlaps with other rectangle. @param other rectangle to check for overlap * @return true if this rectangle overlaps with other rectangle */ public boolean overlaps (Rectangle other) { boolean noOverlap = (other right
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
