Write a class SemiCircle in Java that represents the northern half of a circle i
ID: 3797190 • Letter: W
Question
Write a class SemiCircle in Java that represents the northern half of a circle in 2D space. A SemiCircle has center coordinates and a radius.
Define a constructor:
public SemiCircle(int centerX, int centerY, int theRadius)
Implement the following methods:
public boolean contains(int otherX, int otherY)
returns true if the point given by the coordinates is inside the SemiCircle. Otherwise it returns false. Note: the point will be contained in the SemiCircle if the distance from the center to the print is less than the radius and the point is above the diameter. A point on the circumference or diameter is not contained in the SemiCircle.
public boolean intersects( SemiCircle other)
returns true if the two SemiCircles intersect; otherwise it returns false. Two semicircles "intersect" if at least one, but not all three of the western, northern, and eastern extreme points of one semicircle are contained in the other. This means they do not intersect if one is completely contained in the other or if the extreme point only touches the other semicircle.
Look at the drawing below. The western, northern, and eastern extreme points of the top semicircle are labeled W, N, and E respectively.
In the lower drawing:
The three larger semicircles all intersect
The W point of the green one is inside the black green and black intersect.
The N point of the red one is inside the green green and red intersect.
The E point of the black one is inside the red black and red intersect.
The small blue semicircle does not intersect with any of the large ones.
The blue semicircle and the black one have no points in common => they do not intersect
The blue one and the green one have no points in common => they do not intersect
The blue one is completely contained in the red they do not intersect
------------------------------------------------------------------------------------------------------------------------
The tester is provide :
SemiCircleTester.java
SemicirclesExplanation / Answer
Please check the tester class as some of them are wrong
Above point is below semi1 as its y coordinate is 75 which is less than 100
Similarly,
blue circle is below red circle but it is given as inside circle
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.